Author: remi
Date: 2009-03-23 10:28:43 +0100 (Mon, 23 Mar 2009)
New Revision: 4175
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/util/i18n/I18n.py
Log:
* added doc comments.
Modified: software_suite_v2/tuxware/tuxdroidserver/trunk/util/i18n/I18n.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/util/i18n/I18n.py
2009-03-23 09:18:00 UTC (rev 4174)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/util/i18n/I18n.py
2009-03-23 09:28:43 UTC (rev 4175)
@@ -10,37 +10,59 @@
import os
import locale
+#
------------------------------------------------------------------------------
+# Class to read and use i18n po files.
+#
------------------------------------------------------------------------------
class I18n(object):
+ """Class to read and use i18n po files.
"""
- """
+ #
--------------------------------------------------------------------------
+ # Constructor of the class.
+ #
--------------------------------------------------------------------------
def __init__(self):
+ """Constructor of the class.
"""
- """
self.__locale = locale.getdefaultlocale()[0]
self.__language = self.__locale.split("_")[0]
self.__country = self.__locale.split("_")[1]
self.__poDirectory = None
self.__data = {}
+ #
--------------------------------------------------------------------------
+ # Get the target po directory.
+ #
--------------------------------------------------------------------------
def getPoDirectory(self):
+ """Get the target po directory.
+ @return: A directory path as string.
"""
- """
return self.__poDirectory
+ #
--------------------------------------------------------------------------
+ # Set the target po directory.
+ #
--------------------------------------------------------------------------
def setPoDirectory(self, poDirectory):
+ """Set the target po directory.
+ @param poDirectory: Path of the po directory.
"""
- """
self.__poDirectory = poDirectory
+ #
--------------------------------------------------------------------------
+ # Get the used locale value.
+ #
--------------------------------------------------------------------------
def getLocale(self):
+ """Get the used locale value.
+ @return: The locale as "<language>_<country>" string.
"""
- """
return self.__locale
+ #
--------------------------------------------------------------------------
+ # Set the used locale value.
+ #
--------------------------------------------------------------------------
def setLocale(self, locale):
+ """Set the used locale value.
+ @param locale: Locale to use. "<language>_<country>".
"""
- """
self.__language = locale.split("_")[0]
if len(locale.split("_")) > 1:
self.__country = locale.split("_")[1]
@@ -48,9 +70,16 @@
self.__country = self.__language.upper()
self.__locale = "%s_%s" % (self.__language, self.__country)
+ #
--------------------------------------------------------------------------
+ # Translate a message.
+ #
--------------------------------------------------------------------------
def tr(self, message, *arguments):
+ """Translate a message.
+ @param message: Message to translate.
+ @param arguments: Arguments to pass in the formated message.
+ example:
+ >>>print i18n.tr("This is the {0} test of the module {1}.", 4, "i18n")
"""
- """
if self.__data.has_key(message):
value = self.__data[message]
else:
@@ -60,9 +89,14 @@
value = value.replace("{%d}" % i, str(argument))
return value
+ #
--------------------------------------------------------------------------
+ # Update the internal data dictionary with the current po dictionary and
+ # locale.
+ #
--------------------------------------------------------------------------
def update(self):
+ """Update the internal data dictionary with the current po dictionary
+ and locale.
"""
- """
fileName = "%s.po" % self.__language
poFile = os.path.join(self.__poDirectory, fileName)
if os.path.isfile(poFile):
@@ -87,9 +121,14 @@
except:
pass
+ #
--------------------------------------------------------------------------
+ # Extract the content of a po line.
+ #
--------------------------------------------------------------------------
def __extractContent(self, line):
+ """Extract the content of a po line.
+ @param line: Line to parse.
+ @return: The extracted content.
"""
- """
idx = 0
for i in range(len(line)):
if line[i] != " ":
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn