¿Plantillas de JavaScript con soporte para i18n? (¿y entonces que?)

In a distant future I'd like to distribute my multilingual single-page-application, containing all sorts of resources (videos, texts, interactive applications), for both the web and for the desktop (offline). That dream scenario would also allow translators to access a unified translator dashboard, from where all translations, for all formats, could be crowdsourced.

Pero ese es el futuro.

What I'm looking for short-term is instead an efficient solution for integrating i18n into my JavaScript templates. There should also be some method that can be used when templating is not an option, i.e. when SVG text elements (that should hold translated strings) are added dynamically.

I'm not sure about the pros and cons of doing this server-side (i.e with node.js) - please enlighten me - but it would be nice if the data storage could easily be swapped (from database to files etc.) in case the offline delivery mechanism does not come with database support.

Where should I start, and is there any path that will allow me to build the i18n system incrementally without having to shift the whole paradigm when going from small-scale to big?

preguntado el 08 de noviembre de 11 a las 10:11

1 Respuestas

An idea could be to define a global shortcut like mapping (for instance) _ (underscore) to the translation method of i18n plugin/library whatever s.t. you can then from your JavaScript code (and thus also from within your template) execute calls like


which will return the correctly localized text based on the current language.

This method could then contact a REST service (with proper caching) for retrieving the localized strings from the server where they're somehow managed in files/db tables.

respondido 08 nov., 11:14

Thanks Juri, would you suggest any specific i18n library? - Dani

I'm using jQuery.i18n.properties but I don't know whether it supports fetching properties remotely. You'd have to check on Google, but it shouldn't be too difficult to code it by yourself given that you'd like to create some kind of localization-dashboard in the future as you mentioned. - Juri

Mira esto i18next.com - has to offer clientside and serverside (node.js), support for localstorage and and and... - Jamuhl

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.