Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Conversation

DerGuteWolf
Copy link
Contributor

@DerGuteWolf DerGuteWolf commented Apr 3, 2020

As I wrote in the private messages, this is the first step: localizing a single app.

@DerGuteWolf DerGuteWolf force-pushed the patch-1 branch 2 times, most recently from ba2f8fc to a794c64 Compare Apr 5, 2020
@DerGuteWolf DerGuteWolf force-pushed the patch-1 branch 3 times, most recently from fb3e38e to 79c6477 Compare Apr 19, 2020
.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*/'); });
Copy link

@srl295 srl295 Dec 14, 2020

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!

@gfwilliams
Copy link
Member

@gfwilliams gfwilliams commented Dec 15, 2021

Closing this as we now have a global solution: #136

I've just merged in the translations and made the relevant changes to the alarm app: 26a8755

It's still not possible to enable via the UI but all the basics are there now

@gfwilliams gfwilliams closed this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants