Re:Internationalization (i18n) best practices for front-end ...
by Etheryte on Friday August 11, 2023 @04:38AM
(#37086431)
In general a good short rule of thumb is to always always _always_ write out the full sentence you want to translate and use the tooling to interpolate everything you want to put in it. That way the translator always sees the full context and you make it harder (although not impossible) for yourself to shoot yourself in the foot. Another recommendation I would add is to use two meta locales in development in addition to whatever you need to support otherwise: id and pseudo. The id locale should be an identity function so you (and the translator and everyone else) can open up a page and see what keys are used on that page. The pseudo locale should be either random or pseudorandom text and is good for both ensuring you haven't accidentally left something hardcoded as well as checking how your layout plays with different length strings. These ideas alone will get you most of the way most of the time, and they have the added benefit that they're straightforward to teach to juniors.
[ Parent
| on HN ]
Re:Internationalization (i18n) best practices for front-end ...
by worklaptopacct on Friday August 11, 2023 @08:44AM
(#37088074)
Common translation tools would benefit from the ability to input some domain information. Typing in an entire sentence is a sensible start, but oftentimes a lone sentence does not carry enough context. Example: in my language, the term "fresh water" translates to "fresh water" or "sweet water". "Sweet water" is the opposite of saltwater, while "fresh water" would only be used in a context like "water in a tank has been replaced". The translations in Cities: Skylines use the literal translation and this has always irked me; if the translator accepted "plumbing" as a context, it would have produced a correct translation.
Re:Internationalization (i18n) best practices for front-end ...
by Etheryte on Friday August 11, 2023 @09:13AM
(#37088306)
Most common translation tools already support this. From GNU gettext where it's called context [0], to FormatJS where it's called a description [1], all translation tools worth their salt support providing additional information about the usage. The problem is generally not on the tooling side but on the awareness side, if the person implementing the feature only speaks one language it's easy to overlook issues that wouldn't occur in their native language.
[0] https://www.gnu.org/software/gettext/manual/gettext.html#Con...
Re:Internationalization (i18n) best practices for front-end ...
by holoduke on Friday August 11, 2023 @02:59PM
(#37092487)
If you can tell me how to provide context in the google translation api i would be very happy. Dont think it exists. Only in the web version.
Re:Internationalization (i18n) best practices for front-end ...
by Kerrick on Friday August 11, 2023 @10:57AM
(#37089412)
For what it's worth, the term "fresh water" has each of those separate connotations in American English too, and it can be just as context-dependent. Both "These fish belong in fresh water, not salt water" and "I put fresh water in the ice trays because the old stuff was stale" are valid contextually and linguistically.
Re:Internationalization (i18n) best practices for front-end ...
by fjkdlsjflkds on Friday August 11, 2023 @11:11AM
(#37089571)
Yes, but it does not necessarily have those two connotations in other languages (which is the issue here).
In Portuguese, if you want to say "fresh water" (as in, "low-salinity water"), you use the term "sweet water", rather than "fresh water" ("fresh water" can only be interpreted either as "cold water" or "non-stale water", but never as "low-salinity water").
Re:Internationalization (i18n) best practices for front-end ...
by p3rls on Friday August 11, 2023 @12:16PM
(#37090406)
In English we have the term potable to designate drinkable water, which comes from an old PIEish verb meaning to drink that no one uses anymore and so it's often confused with "pottable" i.e., to be put into a pot, as in a game of pool (a non-aquatic table sport fyi)
Re:Internationalization (i18n) best practices for front-end ...
by dejj on Friday August 11, 2023 @01:19PM
(#37091207)
What does PIEish mean?
Re:Internationalization (i18n) best practices for front-end ...
by mablopoule on Friday August 11, 2023 @01:48PM
(#37091597)
Not op, but I think it stands for Proto-Indo-European language.
Re:Internationalization (i18n) best practices for front-end ...
by atoav on Friday August 11, 2023 @09:07AM
(#37088259)
For special terminology an invaluable trick is to search for the wikipedia article in your language and switch the language if possible. Of course this has to be used with caution, but it can help you find the right variant of a word.
Re:Internationalization (i18n) best practices for front-end ...
by Cicero22 on Friday August 11, 2023 @11:46AM
(#37090017)
A third dev locale worth considering is one which consists of random emojis. Makes it very easy to find hardcoded strings.
Re:Internationalization (i18n) best practices for front-end ...
by the_imp on Friday August 11, 2023 @05:37PM
(#37094356)
Implementing something like an "id" locale is a great idea. Just don't call it that; it's the locale code for Indonesian.
Using a word that's longer than three characters like "identity" will help ensure that it won't conflict with a real locale.