Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi language support #58

Open
lducas opened this issue Jun 17, 2014 · 4 comments
Open

Multi language support #58

lducas opened this issue Jun 17, 2014 · 4 comments

Comments

@lducas
Copy link
Collaborator

lducas commented Jun 17, 2014

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.

@daformat
Copy link
Owner

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.

@lducas
Copy link
Collaborator Author

lducas commented Jun 17, 2014

"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.

@daformat
Copy link
Owner

Haha, sure, let's discuss this later :)

@olance
Copy link
Collaborator

olance commented Jun 17, 2014

don't reinvent the wheel, use Globalize :)

https://github.com/jquery/globalize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants