Formerly JulioFlores.com - random rambllings about web2py, python, Zope and a bit of C#
Home | web2py | ¿Quién Soy? | Contact Me | Language English |   

Last 10
Older Posts
External Links

Add a Comment

Please keep this blog clean, avoid inflamatory, vulgar or otherwise improper comments. Thanks!

Verify your humanity [13996] Please type in the number shown
Name or Email (OPTIONAL - Names or emails will not be used for any other purpose than contacting the sender)
Message

(Some safe-HTML code is allowed only)

Post Original:

English Readers

Well, in a way, that is, all of the menu options and most of the labels, including the contact page, the "who am I" page and error messages, have gone "multilanguage" (or should I say bi-language), I added support for both English and Spanish and German is on its way.

Only thing not translated is the actual contents of the posts, since I write them in either Spanish or English I'll see if I can translate them dynamically as well.

I could not miss trying web2py's clever and easy international support, consider this piece of html markup:

<h2>Add a Comment</h2>

This would be the header of the "Add Comment" view (page), now let's "internationalize" it:

<h2>{{=T('Add a Comment')}}</h2>

Then add a "es.py" in your "languages" folder of your web2py application, and add something like this:

es.py {'Add a Comment': 'Agregar un Comentario'}

And Voila, your code is now multilanguage-aware.

Español

Con excepción de las páginas administrativas, he traducido prácticamente todo el sistema usando los métodos integrados de web2py. Si alguna vez han trabajado en sistemas multilenguaje intentando utilizar métodos estandarizados como el uso de archivos .po por ejemplo, sabrán que no es muy fácil por decirlo de una manera no-frustrante.

web2py provee un patron de traducciones de manera intuitiva y sencilla, utilizando el módulo locale de python y proveyendo un interfáz que (agregando un poco de crítica) aisla al desarrollador de aplicaciones web un poco de la programación en sí.

consideren el siguiente ejemplo en un controller de web2py:

msg = T('Hello World')

Sin haber visto el código fuente para la definición de la clase "T" parece ser un poco de magia negra (y me recuerda mucho a Zope2, o inclusive a C# cuando defines una clase como estática), ¿No necesita "T" una instancia a la cual se le deba de correr un método?, por ejemplo algo asi como:

msg = T('Hello World').render()

Me imagino que __init__ (el constructor) ha de llamar a __str__ para dar esa ilusión, haciendo al programador un poco "flojo" en ese sentido..

A pesar de todo, como he reiterado antes, web2py es una impresionante plataforma de desarrollo y se las recomiendo si quieres atacar lo mejor de ambos mundos, la programacion de computadoras (Python) y eldesarrollo de aplicaciones web (web2py).


 
Proudly Powered by Python

TechFuel.net | Web Standards xhtml 1.1 and css 2.1 | Rel 14