sx.translations (1.2)
by
Olha Pelishok
—
last modified
2009-06-23
Released on 2009-04-16 by Simplistix, Chris Withers for Zope 2.12 under LGPL - GNU Lesser General Public License available for All platforms.
Software development stage: stable
- Homepage of sx.translations: http://pypi.python.org/pypi/sx.translations
- Description source: http://www.simplistix.co.uk/software/zope/sx.translations
An enhanced version of zope.i18n.translationdomain
This package provides components for use with Zope 3 and Zope 2 + Five that implement both ITranslationDomain and ILanguageAvailability as well as supporting the recording of untranslated msgids.
This means that, not only do the components support the interface require to provide message to Zope 3's i18n framework, they can also be used to generate a list of avaiable languages using code similar to the following:
from zope.component import getUtility
from zope.i18n.interfaces import ILanguageAvailability
from zope.i18n.locales import locales, LoadLocaleError
domain = 'myproject'
def getLanguages(self):
options = getUtility(ILanguageAvailability,
domain).getAvailableLanguages()
options.sort()
result = []
for option in options:
lang = option[0]
try:
locale = locales.getLocale(lang)
except LoadLocaleError:
# probably not a real locale
continue
result.append(
{'code':lang,
'name':locale.displayNames.languages[lang],}
)
return result