Dealing with text in software or web projects is always a mess: the customer needs a process for changing and approving content, labels, button descriptions, etc. and we always end up implementing some sort of custom process in Trello, Jira, et.al. The result does not integrate well with the code tools we have.<p>PO files work well for software but don't really interface with customers and approval processes. Adding localisation into the mix makes it even more demanding - now we have to keep track if the original text changes so the translations get updated.<p>How do you solve this?
In my opinion this totally depends on the use case. I came across the following rules for my smaller projects (caution: strongly opinionated):<p><pre><code> - Use a simple key/value structure (you won't need categories/lazy loading, until your app is REALLY big),e.g. {"placeholder": "translation"} in JS
- Use unified access to this structure (Aspect oriented/Service registry/simple function) with a default language fallback - e.g. a function translate('myTranslation');
- If possible, use a very fast but simple key/value data structure (dictionary, array, object, whatever) to store the default translations (static/compile time!)
- Don't try to find automatic solutions for pluralization (just store another key/value pair for the plural[s])
- If you need to switch translations at runtime or update translations on a regular basis (e.g. after updating translations from a db) use a fast, cacheable proxy in front of your key/value thing
- Create a language "placeholders", to see the placeholders used directly in the app just by switching to it
- Don't use constants (because it might be possible that you need to load two languages at a time)
</code></pre>
Just my 2 cents