[tuxdroid-svn] r4839 - in software_suite_v3/smart-core/smart-server/trunk: . data/web_interface/us
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-06-19 13:19:07
|
Author: remi
Date: 2009-06-19 14:50:24 +0200 (Fri, 19 Jun 2009)
New Revision: 4839
Added:
software_suite_v3/smart-core/smart-server/trunk/translation/
software_suite_v3/smart-core/smart-server/trunk/translation/Translation.py
software_suite_v3/smart-core/smart-server/trunk/translation/__init__.py
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po
Modified:
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/index.xsl
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py
Log:
* Added a translation system for the web interfaces
Modified: software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/index.xsl
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/index.xsl 2009-06-19 12:07:29 UTC (rev 4838)
+++ software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/index.xsl 2009-06-19 12:50:24 UTC (rev 4839)
@@ -108,31 +108,31 @@
<xsl:attribute name="class">menuLeftEnable</xsl:attribute>
<xsl:attribute name="id">menuLeft</xsl:attribute>
<xsl:attribute name="onclick">javascript:gotoMenu('livewithtux');return false;</xsl:attribute>
- <xsl:attribute name="href"></xsl:attribute>Live with Tux
+ <xsl:attribute name="href"></xsl:attribute><xsl:value-of select="root/translations/live_with_tux"/>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="class">menuCenterEnable</xsl:attribute>
<xsl:attribute name="id">menuCenter1</xsl:attribute>
<xsl:attribute name="onclick">javascript:gotoMenu('gadgets');return false;</xsl:attribute>
- <xsl:attribute name="href"></xsl:attribute>Gadgets
+ <xsl:attribute name="href"></xsl:attribute><xsl:value-of select="root/translations/gadgets"/>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="class">menuCenterEnable</xsl:attribute>
<xsl:attribute name="id">menuCenter2</xsl:attribute>
<xsl:attribute name="onclick">javascript:gotoMenu('attitunes');return false;</xsl:attribute>
- <xsl:attribute name="href"></xsl:attribute>Attitunes
+ <xsl:attribute name="href"></xsl:attribute><xsl:value-of select="root/translations/attitunes"/>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="class">menuCenterEnable</xsl:attribute>
<xsl:attribute name="id">menuCenter3</xsl:attribute>
<xsl:attribute name="onclick">javascript:gotoMenu('tools');return false;</xsl:attribute>
- <xsl:attribute name="href"></xsl:attribute>Tools
+ <xsl:attribute name="href"></xsl:attribute><xsl:value-of select="root/translations/tools"/>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="class">menuRightEnable</xsl:attribute>
<xsl:attribute name="id">menuRight</xsl:attribute>
<xsl:attribute name="onclick">javascript:gotoMenu('online');return false;</xsl:attribute>
- <xsl:attribute name="href"></xsl:attribute>Online
+ <xsl:attribute name="href"></xsl:attribute><xsl:value-of select="root/translations/online"/>
</xsl:element>
</div>
<div class="ContentView" id="ContentView">
Modified: software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py 2009-06-19 12:07:29 UTC (rev 4838)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py 2009-06-19 12:50:24 UTC (rev 4839)
@@ -2,6 +2,8 @@
# Resource : Web Interface - User 01.
# ==============================================================================
+from translation.Translation import Translation
+
# ------------------------------------------------------------------------------
# Declaration of the resource "wi_user_01".
# ------------------------------------------------------------------------------
@@ -15,6 +17,7 @@
self.name = "wi_user_01"
self.comment = "Resource to manage the web interface - user 01."
self.fileName = RESOURCE_FILENAME
+ self.translations = Translation("wi_user")
# Create an instance of the resource
resourceWIUser01 = TDSResourceWIUser01("resourceWIUser01")
@@ -45,6 +48,7 @@
skin = parameters['skin']
menu = parameters['menu']
contentStruct['root']['data'] = {}
+ contentStruct['root']['translations'] = resourceWIUser01.translations.getTranslations(language)
contentStruct['root']['skin'] = skin
contentStruct['root']['menu'] = menu
contentStruct['root']['language'] = language
Added: software_suite_v3/smart-core/smart-server/trunk/translation/Translation.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/Translation.py (rev 0)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/Translation.py 2009-06-19 12:50:24 UTC (rev 4839)
@@ -0,0 +1,50 @@
+# Copyright (C) 2009 C2ME Sa
+# Remi Jocaille <rem...@c2...>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+import os
+
+from util.i18n.I18n import I18n
+
+# Default list of the supported language.
+SUPPORTED_LANGUAGES_LIST = ["en", "fr", "nl", "es", "it", "pt", "ar", "da",
+ "de", "no", "sv",]
+
+class Translation(object):
+ """
+ """
+
+ def __init__(self, name):
+ """
+ """
+ self.__i18nList = {}
+ self.__updateI18nList(name)
+
+ def __updateI18nList(self, name):
+ """
+ """
+ mPath, mFile = os.path.split(__file__)
+ fullPath = os.path.join(mPath, name)
+ self.__i18nList = {}
+ for language in SUPPORTED_LANGUAGES_LIST:
+ i18n = I18n()
+ i18n.setPoDirectory(fullPath)
+ i18n.setLocale(language)
+ i18n.update()
+ if i18n.getDictionnary() == {}:
+ self.__i18nList[language] = self.__i18nList["en"]
+ else:
+ self.__i18nList[language] = i18n
+
+ def getTranslations(self, language):
+ """
+ """
+ if not self.__i18nList.has_key(language):
+ language = "en"
+ return self.__i18nList[language].getDictionnary()
+
+ def getMsgIDList(self):
+ """
+ """
+ return self.__i18nList.keys()
Added: software_suite_v3/smart-core/smart-server/trunk/translation/__init__.py
===================================================================
Added: software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot (rev 0)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot 2009-06-19 12:50:24 UTC (rev 4839)
@@ -0,0 +1,14 @@
+msgid "live_with_tux"
+msgstr ""
+
+msgid "gadgets"
+msgstr ""
+
+msgid "attitunes"
+msgstr ""
+
+msgid "tools"
+msgstr ""
+
+msgid "online"
+msgstr ""
Added: software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po (rev 0)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po 2009-06-19 12:50:24 UTC (rev 4839)
@@ -0,0 +1,14 @@
+msgid "live_with_tux"
+msgstr "Live with Tux"
+
+msgid "gadgets"
+msgstr "Gadgets"
+
+msgid "attitunes"
+msgstr "attitunes"
+
+msgid "tools"
+msgstr "Tools"
+
+msgid "online"
+msgstr "Online"
Added: software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po (rev 0)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po 2009-06-19 12:50:24 UTC (rev 4839)
@@ -0,0 +1,14 @@
+msgid "live_with_tux"
+msgstr "Vivre avec Tux"
+
+msgid "gadgets"
+msgstr "Gadgets"
+
+msgid "attitunes"
+msgstr "Attitunes"
+
+msgid "tools"
+msgstr "Outils"
+
+msgid "online"
+msgstr "En ligne"
Modified: software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py 2009-06-19 12:07:29 UTC (rev 4838)
+++ software_suite_v3/smart-core/smart-server/trunk/util/i18n/I18n.py 2009-06-19 12:50:24 UTC (rev 4839)
@@ -24,8 +24,8 @@
"""Constructor of the class.
"""
self.__locale = locale.getdefaultlocale()[0]
- if self.__locale == None:
- self.__locale = "en_US"
+ if self.__locale == None:
+ self.__locale = "en_US"
self.__language = self.__locale.split("_")[0]
self.__country = self.__locale.split("_")[1]
self.__poDirectory = None
@@ -73,6 +73,15 @@
self.__locale = "%s_%s" % (self.__language, self.__country)
# --------------------------------------------------------------------------
+ # Get the translation dictionnary.
+ # --------------------------------------------------------------------------
+ def getDictionnary(self):
+ """Get the translation dictionnary.
+ @return: A dictionnary.
+ """
+ return self.__data
+
+ # --------------------------------------------------------------------------
# Translate a message.
# --------------------------------------------------------------------------
def tr(self, message, *arguments):
|