Ver Feed RSS

root@blog:/# chmod o+r *

[Python] Internacionalização (no Linux)

Avalie este Post de Blog
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...

Atualizado 11-01-2010 em 12:56 por Magnun

Categorias
Dicas , Python , Projetos , USBManager

Comentários

  1. Avatar de PotHix
    Æ!!

    Interessante cara! Parabens pelo post!

    Há braços
  2. Avatar de Magnun
    Vlw potHix!

+ Enviar Comentário