M
M
Max Khrichtchatyi2014-08-19 18:18:05
JavaScript
Max Khrichtchatyi, 2014-08-19 18:18:05

Internationalization in JavaScript, how is it?

Tell me how to properly implement Front-End internationalization using JS.
As far as I know, you can include the required ru-js.js or en-js.js file with content like:

ApiMessages={
  "visitor": "Visiteur",
  "me": "Moi",
  "chattingwith": "Vous êtes maintenant en chat avec ",
  "joinedtheroom": " a rejoint le chat",
  "disconnectedmsg": "Vous avez été déconnecté. Tentative de reconnection.",
  "chatsessionclosed": "Session de chat terminée.",
  "hasbeendisconnected": " a été déconnecté.",
  "connecting": "Connection en cours",
  "waitingforuser": "En attente de l'utilisateur",
  "mainwindowtitle": "Fenêtre de chat"
}

more options, plugins, or?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2014-08-19
@Petroveg

Connecting immediately or uploading is a matter of organization. One way or another, it will be a hash. And since the hash, it will most likely be JSON. The variant with XML is possible, but redundant.
Technically, this can be starting from English and choosing to enter the result in cookies or in the address bar (GET parameter with language selection).
Since cookies will come to the server along with the request, it is immediately clear what to issue as JSON included on the page (or a link to the desired file).
If cookies are set and read on the client, then a delay is inevitable (you need to determine what to download, then download and generate content in the desired language). That is, either international inscriptions will replace English ones, or this interface will appear in its entirety only after loading the dictionary.
Cookie alternative. The difference is in the ability to manually change the address bar to the desired language. The downside compared to cookies is instability (in case of accidental distortion of the address bar). Plus - works in Tor and in any situation where cookies are disabled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question