This thing has a term of "internationalization" or "i18n" in short. And most typical approach is to keep all the strings in single place as pair of "key code" -> "actual string" grouped by language.
I don't know what exact languages do you have(with vertical or rtl direction?), but typical challenges here:
someI18nHelper('introductionMessage', { count: timesToClick })
instead of splitting messages someI18nHelper('introductionMessage1') + timesToClick + someI18nHelper('introductionMessage2')
With all this in mind you might choose some solid and powerful system like <code>react-i18next</code>(good overview article: https://phrase.com/blog/posts/localizing-react-apps-with-i18next/). Or you may find that as a overkill for your project and consume something like <code>messageformat</code> as a string processing engine and write loading/switching languages by yourselves. Or finally make your own module to handle all that(that'd not be an effective approach imo).
Hi, is there a way, by any chance, that you could manage your translations using phrase or some tool like this ? (Yup it doesn’t answer you primary question but I hope this could lead you to an easier way to deal with them 🙂)
The rails docs show set some great patterns.
https://guides.rubyonrails.org/i18n.html
I've found this phrase app article to be helpful in the past, too.
https://phrase.com/blog/posts/rails-i18n-guide/
Most likely, you will find that keeping your translations in static yaml files will be the most maintainable solution for most of your translations. But if you need a certain value (like a description) to be editable through a UI, I would follow the yaml pattern and use a combination of the translation key and the language as the primary key for a translations database table. Keep the table decoupled from the model object.
Those are some good tips but there's so much more to watch out for. Especially when it comes to pluralization for example. Check this link to see how fucked some languages are when it comes to counting things: http://cldr.unicode.org/index/cldr-spec/plural-rules
I recommend https://phrase.com/ as a localization management tool to take out the headache of managing a million keys by hand. Haven't stumbled upon a better app for l10n yet.