[Python] Internacionalização (no Linux)
por
em 02-06-2009 às 17:30 (3775 Visualizações)
Continuando o assunto desse post...
Quando fiz a internacionalização do USBManager utilizei um método um pouco diferente do que mostrei anteriormente... Quando fui testar no windows ela não funcionou como deveria. Então bolei aquele código que se mostrou funcional tanto em windows quanto no linux.
Como o USBManager é feito somente para Linux mantive a forma original, que é a mais utilizada por ai... Por isso vou mostar como eu havia feito anteriormente.
O codigo deve ser alterado para o seguinte:
Código :[FONT=Courier New][COLOR=DarkRed]#! /usr/bin/python # -*- coding: utf-8 -*- # File: lang_test.py[/COLOR][/FONT][FONT=Courier New] [/FONT] [FONT=Courier New][COLOR=DarkOrange]import[/COLOR][/FONT][FONT=Courier New] locale [/FONT] [FONT=Courier New][COLOR=DarkOrange]import[/COLOR][/FONT][FONT=Courier New] gettext locale.setlocale(locale.LC_ALL, [/FONT] [FONT=Courier New][COLOR=SeaGreen]''[/COLOR][/FONT][FONT=Courier New]) gettext.bindtextdomain([/FONT][FONT=Courier New][COLOR=SeaGreen]'lang_test'[/COLOR][/FONT][FONT=Courier New], [/FONT][FONT=Courier New][COLOR=SeaGreen]'./locale'[/COLOR][/FONT][FONT=Courier New]) [/FONT][FONT=Courier New]gettext.textdomain([/FONT][FONT=Courier New][COLOR=SeaGreen]'lang_test'[/COLOR])[/FONT][FONT=Courier New] _ = gettext.[/FONT][FONT=Courier New]gettext[/FONT] [FONT=Courier New] [/FONT] [FONT=Courier New][COLOR=DarkOrange]print[/COLOR][/FONT][FONT=Courier New] _([/FONT][FONT=Courier New][COLOR=SeaGreen]'This is a basic internationalization test'[/COLOR][/FONT][FONT=Courier New]) [/FONT]
Para criar o arquivo com as traduções podemos usar o PoEdit da mesma forma, a única diferença é na hora de instala-lo:
$ apt-get install poedit
Pronto, o resto do processo é o mesmo!
Até mais...
Comentários
+ Enviar Comentário