locales = tornado.locale.LOCALE_NAMES
_items = []
for k, v in items:
- for code, locale in locales.items():
- if code.startswith(k):
- k = locale["name"].split()[0]
+ if k:
+ for code, locale in locales.items():
+ if code.startswith(k):
+ k = locale["name"].split()[0]
_items.append((k, v))
items = _items