-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internationalization of alarm app #202
Conversation
ba2f8fc
to
a794c64
Compare
fb3e38e
to
79c6477
Compare
.then( langjson => { | ||
var trans = JSON.parse(langjson); | ||
fileContent = fileContent.replace(/"([^"]*?)"\/\*LANG\*\//g, function(m, p1) { return '"' + (trans[p1]||p1) + '"' + (trans[p1]?'':'/*LANG*/'); }); | ||
fileContent = fileContent.replace(/'([^']*?)'\/\*LANG\*\//g, function(m, p1) { return "'" + (trans[p1]||p1) + "'" + (trans[p1]?'':'/*LANG*/'); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is clever, but I think it would be better to just use a function in the callsite, something like https://www.i18next.com/translation-function/essentials#passing-a-default-value (and many others) use:
locale.t('new', 'New Alarm')
Using the English (here) as the key is not good, if the English text “New Alarm” changes, then you can't reuse the translations properly.
Actually, there's already a locale.translate function: https://www.espruino.com/Bangle.js+Locale#translation
but it uses the English text, and doesn't support Application resources.
Needs some work!
As I wrote in the private messages, this is the first step: localizing a single app.