;ò Mùe?c@sIdZdkZd„Zed„Zed„Zed„ZeƒZdS(s‚If you want your program to be translated into multiple languages you need to do the following: - Pass all strings that should be translated through the '_' function, eg: print _('Hello World!') - Create a Messages subdirectory in your application. - Run 'pygettext *.py' to extract all the marked strings. - Copy messages.pot as Messages/.po and edit (see ROX-Lib2's README). - Use msgfmt to convert the .po files to .gmo files. - In your application, use the rox.i18n.translation() function to set the _ function: __builtins__._ = rox.i18n.translation(os.path.join(rox.app_dir, 'Messages')) (for libraries, just do '_ ='; don't mess up the builtins) Note that the marked strings must be fixed. If you're using formats, mark up the format, eg: print _('You have %d lives remaining') % lives You might like to look at the scripts in ROX-Lib2's Messages directory for more help. NcCs±dkl}||ƒ}dd>} dd>}dd>} d}|idƒ}|djo"||} || }|| O}nd} |idƒ}|djo"||} || }|| O}nd} |idƒ}|djo"||}|| }||O}nd}|}g}x‡t |dƒD]u}||@ ob|} ||@o| |7} n|| @o| | 7} n|| @o| | 7} n|i| ƒq&q&W|iƒ|SdS( N(s normalizeiiis@ss.s_(slocales normalizesCOMPONENT_CODESETsCOMPONENT_TERRITORYsCOMPONENT_MODIFIERsmasksfindspossmodifierscodesets territoryslanguagesretsrangesisvalsappendsreverse(slocales normalizes territorysislanguagesCOMPONENT_TERRITORYsmaskspossretsCOMPONENT_CODESETsCOMPONENT_MODIFIERsvalscodesetsmodifier((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pys _expand_langsN                   cCsÓ|tjoTg}xKddddfD]3}tii|ƒ}|o|idƒ}Pq&q&Wnd|jo|idƒng}xC|D];}x2t |ƒD]$}||jo|i|ƒqŸqŸWqŒW|SdS(NsLANGUAGEsLC_ALLs LC_MESSAGESsLANGs:sC( s languagessNonesenvarsossenvironsgetsvalssplitsappendsnelangsslangs _expand_langsnelang(s languagesslangsvalsnelangssenvarsnelang((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pysexpand_languagesGs$     cCsexZt|ƒD]L}|djoPntii|d|ƒ}tii|ƒo|Sq q Wt SdS(sµLook in messages_dir for a .gmo file for the user's preferred language (or override this with the 'languages' argument). Returns the filename, or None if there was no translation.sCs%s.gmoN( sexpand_languagess languagesslangsosspathsjoins messages_dirsmofilesexistssNone(s messages_dirs languagesslangsmofile((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pysfind\s   cCsEt||ƒ}| o d„Sndk}|it|ƒƒiSdS(szLoad the translation for the user's language and return a function which translates a string into its unicode equivalent.cCs|S(N(sx(sx((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pysnsN(sfinds messages_dirs languagessmofilesgettextsGNUTranslationssfilesugettext(s messages_dirs languagessgettextsmofile((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pys translationis   (s__doc__soss _expand_langsNonesexpand_languagessfinds translationslangs(s _expand_langsexpand_languagess translationslangssossfind((sR/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/i18n.pys?s   )