Open lducas opened 10 years ago
Yes, though it's kind of the same, here are my 2 cents:
We can use a helper function with a string ID parameter, and a javascript object for the translations. Quick implementation would look something like this :
var culture = 'String ID (eg. "FR")'; // might want to default this to EN if not auto detected
i18n = function(id){
return translations[culture][id] || id; // we return the string id if no translation was found
};
Our translation object :
var translations = {
'FR': {
'some string id': 'corresponding translation',
'some other string id': 'corresponding translation',
...
}
};
We'll probably implement an alias for the i18n function such as var __ = i18n;
as it'll tend to get used very often.
On top of this, we'll probably want to implement some proper templating engine for html translations so we don't have to javascript document.write(translation)
all the time
Please note: We need to think about the fact that the meta won't get translated this way, as google robots and social scrappers don't execute JS.
"JS mumble, template mumble mumble." I guess I should leave this to the pros... But I can surely help crawling through all files to detect and mark all texts needing translation.
Haha, sure, let's discuss this later :)
don't reinvent the wheel, use Globalize :)
We should here discuss how to integrate multi language support in Cryptris.
With my poor programming skills I see two options. Opinions or other suggestions welcomed !
Solution 1: Replace all literal text by a call to a function translate with the same text (in French) as an argument. The function translate access a table with corresponding translation.
Solution 2: Replace all literal text by a variable that are defined in a single file, and modify the value of those variable depending on the language.