When ES2015 came out with the template strings (as that was its name there) i cheered the old Great Lisp Macros would be on the way to go back but it was the premature overestimating. Nevertheless i quickly found a good real use of the literals besides just being handy.

The idea is to have in React:

and to see in a browser:

Привет, Мир

The dirty, quick, but still long living implementation is as easy as to have a JSON object with the translations like this:


and a module implementing T


What’s the reason to invent a wheel instead of picking up one of the miriads others l18n modules? The main reason is “miriads”. Really it is much faster to get this small module done than to waste hours if not days trying to choose “the best” from the npm pile. Another reasons are “flexibility” and “risk free” — once we in S4Y needed to have few versions of wordings in the same language and it cost us nothing to change the getting “locale” from http header to mobx observable and we are sure we will adopt this homebrew solution in countable minutes/hours in case of the unexpected requirements.

And besides all it is pretty.

Categories: Development

Leave a Reply

Your email address will not be published. Required fields are marked *