Hacker News new | ask | show | jobs
by JanSt 709 days ago
have you thought about automatically generating json language files from pure html? Say I have an app that does not yet use a language file but just code like

<strong>Hello World</strong>

And on-the-fly translation? Say I have a backend that returns english language but I need it to translate it to another language on the fly? It could check whether the translation is available and otherwise generate it and store it. The original text key could be a hash of the text and you probably need in-memory key lookup for those hashes.

1 comments

"you have 3 items in your cart" would in that case create a translation for each time the amount changes, instead of having "you have {{count}} items in your cart. A backend proxy sounds like an interesting idea, but working with an i18n formatted string from the start seems like a more sustainable approach.