Hacker News new | ask | show | jobs
by tqkxzugoaupvwqr 3151 days ago
The solution is: Build support for translations into your code and only offer English as language. You can later add additional languages without having to replace every hardcoded text with a translation ID.

The most basic version of how it works: Where you want your translated text, put a function, e.g. called “T” that takes a string as argument and returns a string. The function uses this argument (translation ID) to look up the actual translation in a map.

2 comments

Unfortunately that's only a partial solution. Some languages produce much longer text than English, either by using more words or just longer words. If you design the UI with only English text lengths, then you'll still need to redo the UI layout. Similar problems for languages which aren't read from left to right like English.
This is an extremely naive way to look at i18n. Especially for UI’s, it’s much more difficult. Dynamically formatted strings, sentence direction, capitalization, etc. aren’t solved by what boils down to a key-value map.