Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Use user's locale as default app language #59

Merged
merged 5 commits into from Feb 14, 2018
Merged

Use user's locale as default app language #59

merged 5 commits into from Feb 14, 2018

Conversation

ItsANameToo
Copy link
Member

When starting the app for the first time, you'll see a short introduction. This introduction was not properly translated when you set a different language, as the translationService still returned the English values. I've deferred the retrieval of the translations by waiting for the platform.ready() call, but I am not sure whether this is the right way to go. If there is a better way to wait for a translation to be set in Ionic, then let me know!

If you want to review this issue, you can do so as follows:

  1. In app/app.components.ts, set a different language than 'en' (e.g. 'nl'):
    this.translateService.use('nl'); // Set your language here

  2. Reinstall the app so you'll see the introduction again. The introduction slides will be in English, while the buttons will be translated into the correct language

  3. Apply the fix in this PR and now the slides should be translated as well!

@ItsANameToo
Copy link
Member Author

Any help with the lint issue is also appreciated! It states that Property 'platform' is declared but its value is never read., but I call the ready() function on platform, so I don't see why I'm getting this error.

@Nasicus
Copy link
Contributor

Nasicus commented Feb 10, 2018

Don' declare platform as private, because you only use it within the constructor :)
Good catch btw 👍

@ItsANameToo
Copy link
Member Author

@Nasicus Thanks for the info!

@Nasicus
Copy link
Contributor

Nasicus commented Feb 10, 2018

Making it public let's disappear the lint error however it's still not correct :)
If you only need it in the method just declare it as platform: Platform.
If you do it like that it's not a "class" member and get's "lost" as soon as the constructor exists, which is what you want at the moment.

@ItsANameToo
Copy link
Member Author

I see, still getting used to Ionic so your explanation is much appreciated! Thanks again! :)

@Nasicus
Copy link
Contributor

Nasicus commented Feb 10, 2018

You're welcome.

Though it's not ionic, it's a feature from typescript.

@luciorubeens
Copy link
Contributor

Well, even with this PR the user will continue to see in English because the settings are changed after logging into the profile. So we need to change the default language on model and use translateService.getBrowserLang() instead.

@ItsANameToo
Copy link
Member Author

@luciorubeens That's true, I'll take a look into adding the user's locale as the default language in the settings!

@ItsANameToo
Copy link
Member Author

@luciorubeens The app now tries to use the user's locale as default language. I check agains the currently available translations to see if the locale is available; if it isn't: it reverts to English as default language

@ItsANameToo ItsANameToo changed the title Deferred intro translations Use user's locale as default app language Feb 11, 2018
@luciorubeens luciorubeens merged commit 2f37077 into ArkEcosystem:master Feb 14, 2018
@luciorubeens
Copy link
Contributor

Great, thanks! 👍🏻

@alexbarnsley
Copy link
Member

I like this! 👌

@ItsANameToo ItsANameToo deleted the defer-translations branch February 15, 2018 20:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants