shri-2015-org / shrimp

Shrimp chat application by ShrimpJS SHRI-2015 team
http://188.226.253.9/
MIT License
10 stars 5 forks source link

feat: localization support #298

Closed dimaip closed 8 years ago

dimaip commented 8 years ago

Add support for classical gettext style localization. Wrap any message with __('Text to translate'). This localization function is passed down in React context from App file, and is automatically updated with correct message strings, user preference is set in local.language state.

Important gotcha is to check for context changes in every of shouldComponentUpdate calls, otherwise that part of app will stay in English.

We're using custom grep-based script to extract messages from source code, as none of the solutions are working with jsx files properly.

In addition to that, our project recived an opensource license from Crowdin: https://crowdin.com/project/shrimpjs

Localization workflow:

This whole process could be automated via crowdin-cli and API, possibly in a CircleCI job, but I don't feel like doing it at the moment.

One problem with this implementation, is that available languages are hardcoded in various places. However it is not easy to fix it, as we currently don't have a single place settings, which would both be available on the client and server side. Once it is fixed, it would be fairly easy to replace hardcoded languages.

Closes: #297