-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add i18next and transifex into the project #875
Conversation
1f87778
to
d92a4f4
Compare
a4edb28
to
aab7255
Compare
@@ -41,6 +43,7 @@ export const createClient = async (instance: string): Promise<CozyClient> => { | |||
const stackClient = client.getStackClient() | |||
stackClient.setUri(instance) | |||
await stackClient.register(instance) | |||
await changeLanguage(client.getInstanceOptions().locale) |
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.
changeLanguage() called here
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.
Is client.getInstanceOptions()
supposed to work when not logged yet?
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.
My understanding is that the locale will change:
- On not-logged startup based on device's locale
- During login just after creating a cozy-client, so the password screen would have the cozy's language
- On logged startup based on cozy's language
But:
- We don't revert to device's language on logout or on revoked token event (i don't remember if it is what we want)
- We don't revert to device's language if we stop the login process
Should we implement those ?
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.
we could implement that, you would have the cozy language in memory here indeed (but it would reset next app launch). I'm not sure what is best for the user here
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.
Is
client.getInstanceOptions()
supposed to work when not logged yet?
it doesn't work indeed. I'm not sure where to put it, there are a lot of options. Can't we use a single call for both login and creation?
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.
getClient, finalizeClient, check if lang can be used before login, add a fallback in nav to check if lang is correct
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.
set phone lang on welcome screen
src/libs/client.js
Outdated
@@ -63,6 +64,7 @@ export const getClient = async () => { | |||
|
|||
await client.registerPlugin(flag.plugin) | |||
await client.plugins.flags.initializing | |||
await changeLanguage(client.getInstanceOptions().locale) |
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.
changeLanguage() called here
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.
maybe it should be called only once for all cases. not sure where
@@ -10,15 +10,18 @@ | |||
"home:build": "(cd cozy-home && yarn build:mobile)", | |||
"home:watch": "(cd cozy-home && yarn watch:mobile)", | |||
"install:home:local": "bash ./scripts/install-home.sh", | |||
"install:home:registry": "yarn tsc --project scripts && node scripts/dist/install-home-registry.cmd.js", | |||
"install:home:registry": "node scripts/dist/install-home-registry.cmd.js", | |||
"install:scripts": "yarn tsc --project scripts && yarn install:home:registry", |
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.
You refactored this but you didn't change the behavior. Did you intialy want to add the validate:locales script here?
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.
yes but now it also compiles the validation script that is in ts, so I wanted to compile them only once and not twice. By doing it in the postinstall this is ensured
src/locales/i18n.ts
Outdated
export const t: TranslationFunction = (...args) => _i18n.t(...args) | ||
export const useI18n = (): UseTranslationResult => useTranslation() | ||
export const changeLanguage: ChangeLanguageFunction = languageCode => | ||
_i18n.changeLanguage(languageCode) |
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.
Shouldn't we check for supported language here? So the day we will add a new language in cozy-settings we don't need to be synchronized with a new flagship app release
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.
yes, what should we do if it's not supported? switch to english or stay on es/fr?
- Updated
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.
If the language is available then take this language
Else try to take the phone's language
Else if phone's language not available, then take english
@@ -41,6 +43,7 @@ export const createClient = async (instance: string): Promise<CozyClient> => { | |||
const stackClient = client.getStackClient() | |||
stackClient.setUri(instance) | |||
await stackClient.register(instance) | |||
await changeLanguage(client.getInstanceOptions().locale) |
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.
Is client.getInstanceOptions()
supposed to work when not logged yet?
@@ -41,6 +43,7 @@ export const createClient = async (instance: string): Promise<CozyClient> => { | |||
const stackClient = client.getStackClient() | |||
stackClient.setUri(instance) | |||
await stackClient.register(instance) | |||
await changeLanguage(client.getInstanceOptions().locale) |
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.
My understanding is that the locale will change:
- On not-logged startup based on device's locale
- During login just after creating a cozy-client, so the password screen would have the cozy's language
- On logged startup based on cozy's language
But:
- We don't revert to device's language on logout or on revoked token event (i don't remember if it is what we want)
- We don't revert to device's language if we stop the login process
Should we implement those ?
2411998
to
15164a3
Compare
- Add CI check - Add TX config - Add TX pull script - Add a locale check script - Add translation files - Add i18n service - Install required dependencies - Add mocks - Add types
97113c3
to
0faf788
Compare
- At prelogin - At login - At logout
0faf788
to
71a5072
Compare
const { kdfIterations, name, locale } = await fetchPublicData(client) | ||
|
||
// If we are able to get a locale from the public data, we update the language asap | ||
if (locale) void changeLanguage(locale) |
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.
setInstanceData
is called only for classic login, in case of magicLink based auth then startMagicLinkOAuth
is called and in case of OIDC oauth then startOidcOAuth
is called. During those scenario we can have the 2FA screen displayed that should be translated too.
Also I'm wondering if we have enough data to do the same on the OnboardingScreen?
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.
I suggest doing this in a following PR as getting locale info before full login wasn't really in the scope of this feature at the start
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.
I'm ok with that 👍
Implementations