Author: remi
Date: 2009-09-17 10:43:55 +0200 (Thu, 17 Sep 2009)
New Revision: 5426

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetDescription.py
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcDescription.py
Log:
* Added a normalization of the ugc name. When you switch the global language, 
the ugc with an original name (Clock, weather) are translated in the new 
language.

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetDescription.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetDescription.py
  2009-09-17 07:52:14 UTC (rev 5425)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetDescription.py
  2009-09-17 08:43:55 UTC (rev 5426)
@@ -5,6 +5,8 @@
 
 import os
 
+from util.applicationserver.plugin.Plugin import SUPPORTED_LANGUAGES_LIST
+
 # 
------------------------------------------------------------------------------
 # Gadget description class.
 # 
------------------------------------------------------------------------------
@@ -105,6 +107,32 @@
             return self.__parent.tr2(language, self.__name)
 
     # 
--------------------------------------------------------------------------
+    # Normalize a gadget name with the correct translation.
+    # 
--------------------------------------------------------------------------
+    def normalizeName(self, name):
+        """Normalize a gadget name with the correct translation.
+        @param name: Gadget name to normalize.
+        @return: A string.
+        """
+        isTr = False
+        trLang = None
+        for lang in SUPPORTED_LANGUAGES_LIST:
+            trName = self.getTranslatedName(lang)
+            if name.find(trName) == 0:
+                isTr = True
+                trLang = lang
+                break
+        if isTr:
+            tgLang = self.__parent.getContainer().getLanguage()
+            if tgLang != trLang:
+                tgName = self.getTranslatedName(tgLang)
+                return name.replace(trName, tgName)
+            else:
+                return name
+        else:
+            return name
+
+    # 
--------------------------------------------------------------------------
     # Get the TTS name of the gadget.
     # 
--------------------------------------------------------------------------
     def getTtsName(self, language = None):

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcDescription.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcDescription.py
        2009-09-17 07:52:14 UTC (rev 5425)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcDescription.py
        2009-09-17 08:43:55 UTC (rev 5426)
@@ -56,6 +56,7 @@
         self.__dictionary = dictionary
         # Get the descriptor values
         self.__name = dictionary['name']
+        self.__name = 
self.__parent.getParentGadget().getDescription().normalizeName(self.__name)
         self.__ttsName = self.__name
         if dictionary.has_key('ttsName'):
             self.__ttsName = dictionary['ttsName']


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to