Home | Trees | Indices | Help |
|
---|
|
object --+ | EggTranslations
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
_NAME =
|
|
|||
_fallback | |||
_gtCache | |||
_iniCache | |||
_iniEncoding | |||
_iniFileName | |||
_init | |||
_localeCache | |||
_localeSet | |||
_moCache | |||
Inherited from |
|
|
The initialize method sets the locale set and loads the resource and translation caches. It must be called before using the EggTranslations API. The initialize method can only be called once per EggTranslations instance.
|
returns True if a key was specified in one or more eggs resource ini files (default is "resource.ini") for the given project and name. The locale is an optional argument. By default the locale set is searched in fallback order as well as the 'all' default locale (if fallback=True in the initialize or setLocaleSet method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale.
|
Returns the unicode string value that was specified in one or more eggs resource ini files (default is "resource.ini") for the given project and name. or None if not found. The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale. Example: If you have aresource.ini file containing the following
entry:
[MyProject::fr] myimage = /resources/imgs/myimage.pngthen: >>> print eggRMInstance.getValueForKey("MyProject", ... "myimage", "fr") /resource/imgs/myimage.png
|
The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale.
|
Returns a The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale.
|
Example: If you have aresource.ini file containing the following
entry:
[MyProject::fr] myResource=/resources/myresource.pngthen: >>> print eggRMInstance.hasResource("MyProject", ... "myResource", "fr") True
|
Returns a The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale.
|
Returns a The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale.
|
Returns a The locale is an optional argument. By default the locale set is searched in fallback order (if fallback=True in the initialize or setLocale method) until a key is found. If no key found the method returns False. However, if a locale is specified the method will only search for a key in the resource ini files for the given locale. Example: If you have aresource.ini file containing the following
entry:
[MyProject::all] myDocument = README.txtThen you could retrieve the entire contents of README.txt
as a unicode string via:
>>> f = eggRMInstance.getResourceAsString("MyProject", ... "myDocument", ... "all") >>> f u'This is the text contained in the readme file'
|
Returns a An optional additional argument can be specified as the default value to return if no localized is found. The txt parameter will be returned by EggTranslations.getText if no localized value found for the txt parameter. However, if the default value argument is passed, that value will be returned instead of text. Example where there in no localized value for txt parameter "Hello World":>>> eggRMInstance.getText("MyProject", "catalog", ... "Hello World") u'Hello World' >>> >>> eggRMInstance.getText("MyProject", "catalog", ... "Hello World", ... None) None >>> If fallback was set to True in the EggTranslations.initialize method or the EggTranslations.setLocaleSet method, the EggTranslations.getText method will search all locales in the locale set till a gettext mo translation is found for the txt parameter. If fallback was set to False in the EggTranslations.initialize method or the EggTranslations.setLocaleSet method, the EggTranslations.getText method will only search the current locale, which is the first locale in the locale set for a gettext mo translation for the txt parameter. Note that the "all" default locale can not contain any key value pairs that point to gettext .mo files. If a .mo gettext value is found in the "all" default locale, the .mo file will not be loaded by the EggTranslations. Example: A resource.ini file contains the following entry:[MyProject::fr] catalog = locale/fr/MyProject.moThe locale/fr/myproject.mo file contains a localization of "Hello" to "Bonjour". Then, calling EggTranslations.getText looks this up in the .mo file:
>>> egRMInstance.initialize("fr") >>> eggRMInstance.getText("MyProject", "catalog", ... "Hello") u'Bonjour'
|
|
|
list of the locales that have registered one or
more key value pairs for the given project.
|
Returns the
|
list of valid str locale language
/ country codes. The list is arranged in ascending fallback
order.
|
Resets the EggTranslations locale set Resetting the locale set includes unloading all gettext .mo translations, loading the the gettext .mo translations for the current locale set, and setting the gettext locale fallback order if the fallback parameter is set to True. Note the initial locale set for the EggTranslations must be set in the EggTranslations.initialize method. Note, setting the EggTranslations locale set also adds the language code as a fallback for language / county code locale definitions when fallback is set to True. If the locale set contains 'fr_CA' this method will also add to the locale set 'fr' as a fallback for 'fr_CA'.
|
Normalizes the Thus if passed "Fr_cA" this method would return "fr_CA". If passed "FR" this method would return "fr"
|
Returns True if the str matches a
valid ISO code. Only that the form of the str is
correct.
|
Adds the lang code, if not already present, to the localeSet as a fallback to the lang country code. Thus if passed ["fr_CA", "en_US", "es"] this method would return ["fr_CA", "fr", "en_US", "en", "es"]
|
Returns a EggTranslations ========================= INI FILE: ResourceFileName (Encoding) LOCALE SET: [localeSetValues] FALLBACK: True | False EggName =============================== ProjectName --------------------- [LocaleName] entryKey=entryValue gettextKey=getTextMoFile (LOADED | NOT_LOADED) Here's an additional example output using real values:: EggTranslations ========================= INI FILE: 'resources.ini' (UTF-8) LOCALE SET: ['fr_CA', 'fr'] FALLBACK: True MyProject 0.1 =============================== myProject ------------------------- [all] splashScreenImage = imgs/splash.png readme = README.txt myAlternateProject ------------------------- [all] splashScreenImage = alternate/imgs/splash.png readme=alternate/README.txt MyProject.fr 0.1 =============================== myProject ------------------------ [fr_CA] splashScreenImage = locale/fr/imgs/splash.png readme = locale/fr/README.txt catalog= locale/fr/myProject.mo (LOADED) myAlternateProject ------------------------ [fr_CA] splashScreenImage = alternate/locale/fr/imgs/splash.png readme = alternate/locale/fr/README.txt catalog = alternate/locale/fr/myProject.mo (LOADED)
|
Callback method passed to
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed Feb 11 16:25:11 2009 | http://epydoc.sourceforge.net |