From 6af40477a1a2f860d3f52389f4e0171261e80dbd Mon Sep 17 00:00:00 2001
From: Michael Tremer
Date: Tue, 4 Jan 2011 20:40:16 +0100
Subject: [PATCH] fireinfo: Write correct name for languages.
---
www/templates/stasy-stats-geo.html | 2 +-
www/webapp/ui_modules.py | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/www/templates/stasy-stats-geo.html b/www/templates/stasy-stats-geo.html
index ee296e7..514d6b3 100644
--- a/www/templates/stasy-stats-geo.html
+++ b/www/templates/stasy-stats-geo.html
@@ -8,7 +8,7 @@
This will give a short overview about what languages are configured
on the IPFire webinterface.
- {{ modules.StasyTable(languages, sortby="percentage", flags=True) }}
+ {{ modules.StasyTable(languages, sortby="percentage", locale=True) }}
{{ _("Geo locations") }}
diff --git a/www/webapp/ui_modules.py b/www/webapp/ui_modules.py
index a3964ff..ebbc19c 100644
--- a/www/webapp/ui_modules.py
+++ b/www/webapp/ui_modules.py
@@ -8,6 +8,7 @@ import operator
import socket
import textile
import tornado.escape
+import tornado.locale
import tornado.web
from tornado.database import Row
@@ -141,7 +142,7 @@ class TrackerPeerListModule(UIModule):
class StasyTableModule(UIModule):
- def render(self, items, sortby="key", reverse=False, percentage=False, flags=False):
+ def render(self, items, sortby="key", reverse=False, percentage=False, flags=False, locale=False):
hundred_percent = 0
for v in items.values():
hundred_percent += v
@@ -174,6 +175,17 @@ class StasyTableModule(UIModule):
_items.append((k, v))
items = _items
+ if locale:
+ flags = False
+ locales = tornado.locale.LOCALE_NAMES
+ _items = []
+ for k, v in items:
+ for code, locale in locales.items():
+ if code.startswith(k):
+ k = locale["name"]
+ _items.append((k, v))
+ items = _items
+
return self.render_string("modules/stasy-table.html", items=items, flags=flags)
--
2.39.5