Multi Language Content (MLC), a new approach

In a previous post, I wrote about the idea of remove MLS from core in Xaraya 2.0 and the need of a module to translate dynamic content, as well GUI files.
I’ve been reorganizing mi ideas, and investigating how other CMS and blogs do it, and yesterday i was talking with MichelV and Jojode in channel #support of Xaraya IRC when i saw the light
My idea is the creation of an utility module, Multi Language Content (or MLContent), that can be hooked by any other content module and let it show translated content. It avoid the complexity of integrate it with core, and let site admin decide what module can handle translations. It also allow all users use it in recent 1.0.x releases of Xaraya.
The key is that it must be simple. In my previous post i give some ideas, but they are very complex and require a lot of code and processing. Searching how other CMS do it I found some modules to Wordpress that allow multi language content, such as Polyglot (the one we’re using in this blog), and the idea is so simple that i loved it
. They use a tag such as < lang_xx >…< /lang_xx > or [ lang_xx ]…[ /lang_xx ], and it shows or hide the content based on marqued current locale or get var, all in the same text area, and give an output code to show a list of flags to can view the content in other languages present in the content.
Talking with MichelV we thought that it could also be easily done parsing translated strings with (x)html compliance code, using lang or xml:lang (for XHTML 1.1, that eliminates lang attribute from the DOCTYPE) attributes. Then, the module parse all content and show or hide it depending of the current user locale and the attributes of the code. We only need to avoid translate or parse nested tags with the attributes (to let editors create accessible and semantic code). It also could be easily implemented in WYSIWYG editors such as TinyMCE.
It could be easily done with javascript and DOM, even with CSS, but i think that it’s a best work to the server (due to leack of support of DOM and css selectors in some browsers), so i’m trying with DOM classes of PHP. I’ll write here all advances that i get with this module
En un artículo anterior escribí sobre la idea de eliminar el MLS del núcleo de Xaraya 2.0 y la necesidad de un módulo que tradujera el contenido dinámico, así como la GUI.
he estado reorganizando mis ideas, e investigando cómo lo hacen otros CMS y blogs, y ayer estaba hablando con MichelV y Jojode en el canal #support del IRC de Xaraya cuando vi la luz
Mi idea es la creación de un módulo de utilidad, Multi Language Content (o MLContent), que pueda ser enganchado por cualquier otro módulo de contenido y le permita mostrar el contenido traducido. Esto evita la compeljidad de integrarlo en el núcleo, y le permite al administrador del sitio decidir qué módulo gestiona traducciones. También permite usarlo a los usuarios de la versión 1.0.x de Xaraya.
La clave es que sea simple. En mi mensaje anterior di algunas ideas, pero eran demasiado compejas y requieren un montón de código y proceso. Buscando cómo lo hacen otros CMS encontre algunos módulos para Wordpress que permiten la creación de contenido en varios lenguajes, como Polyglot (el que usamos en este blog), y la ide es tan simple que me enamoré
. Usan unsa etiquetas con el formato < lang_xx >…< /lang_xx > o [ lang_xx ]…[ /lang_xx ], y muestran u ocultan el contenido basándose en la localización actual o en una variable get, todo en la misma área de texto, y también provee el código para mostrar una lista de banderas para ver el contenido existente en otros lenguajes presentes en el texto.
Hablando con MichelV pensamos que esto podía ser fácilmente hecho con código estandar (x)html, usando los atributos lang o xml:lang (para XHTML 1.1, que elimita el atributo lang de su DOCTYPE). Entonces, el módulo comprueba el contenido y lo muestra u oculta dependiendo de la localización actual del usuario y los atributos en el código. Solo debemos tener cuidado para no procesar las etiquetas con estos atributos que se encuentren anidadas (para dejara los editores crear código accesible y semántico). También podría implementarse fácilmente en editores WYSIWYG como TinyMCE.
Esto podría hacerse fácilmente con javascript y DOM, incluso con CSS, pero pienso que serí amejor hacerse en el lado del servidor (debido a la falta de soporte de DOM y selectores CSS en algunos navegadores), así que estoy probando con las clases DOM de PHP. Escribiré por aquí mis progresos con este módulo
.

