We're working on a web based video game: https://colonist.io/
We're interested in internationalizing our product and need advice on how we should handle it. i18next seemed like a well-designed framework with a lot of plugins that allow for integration with all kinds of different products, but after some research and testing we're finding some difficulties in gettings things to work in a way that is suitable for us.
We use Typescript across our code base. On the server side, we are using Express (Node.JS) to handle APIs and render EJS templates. On the client side, we're are not using any special library or framework, just vanilla Typescript, with SASS for styling and PIXI.js for game rendering. We use Webpack for bundling.
We have 3 folders, server, client, shared.
Currently, We have texts in multiple places in the code base:
- Texts inside a
sharedtext file, that can be accessed both from theserverandclient. - Texts directly inside
EJStemplates. - Texts directly inside TS code, both on the
serverandclient.
Ideally, the system should work so that:
- On the server side:
a. Easy to tie a locale to a http request/API request/socket connection (we're fine with disconnecting sockets when the language is changed)
b. Easily use the localized texts in
EJStemplates c. Localize renderingSASSwhen needed (if style needs special rule for both LTR and RTL, etc...) - On the client side:
a. Code should only load the resources necessary for the selected locale (so no downloading Spanish for an English user).
b. Preferable handled by
Webpackbundles and away from explicitly requesting resources asynchronously. c. Caching. - Shared locales; no need to create separate files for the server and client.
- Easy to add new entries, we'll probably automatically add or use
GitHub Copilot/Google Translatefor the majority of the texts. - Isolated languages/locales, not everything in one file.
- Auto detect strings that need translation and giving notice.
Questions:
- Would it be possible to achieve this directly with already-built plugins?
- If not all, which can and which cannot?
- How hard would it be to implement our own approaches for thing that don't work out of the box? Will it be difficult to do or prone to break? Will it need constant updates?
- Are there other frameworks that can achieve this (and still handle most i18n cases like plurals, formatting, etc...)?