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

[RN] Fix internationalization on mobile #2318

Merged
merged 1 commit into from
Jan 26, 2018
Merged

Conversation

saghul
Copy link
Member

@saghul saghul commented Dec 22, 2017

Only the first commit is necessary to fix the Android crash, but I thought I'd try to add actual internationalization support, hence commit number 2.

I'd like to hear thoughts on the implementation :-)

Here is how it looks like in Spanish screenshot is on Android, but I also tested iOS):

screenshot_20171222-112543

As you can see, dates are not translated, maybe @zbettenbuk can take a look at that.

@zbettenbuk
Copy link
Member

I think I found the issue. i18next returns different locale format names of what momentjs requires. This also leads to a crash I found today, when the React native app runs in prod mode. Added it to Jira, will fix it first thing.

@saghul
Copy link
Member Author

saghul commented Dec 23, 2017

Does it crash with the first commit applied? I didn’t run in release mode though...

@zbettenbuk
Copy link
Member

Haven't checked it with this PR yet, i found the crash with the master.

@saghul
Copy link
Member Author

saghul commented Jan 3, 2018

@paweldomas I believe @lyubomir wanted to have a look at the 2nd commit, but you should be able to merge the first, since current master is broken on non english locales, and this fixes it.

@saghul
Copy link
Member Author

saghul commented Jan 8, 2018

Rebased + force pushed now that the first commit landed. The remaining commit just adds the builtin translations.

@saghul
Copy link
Member Author

saghul commented Jan 19, 2018

@lyubomir Do you still want to take a look at this?

{
name: 'bg',
mainResource: BG_MAIN,
langResource: BG_LANG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saghul, I'm afraid I don't understand the purpose of langResource! I don't see it used anywhere (in the file given that languages is not exported out of the file).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If langResource is not necessary, could we please maybe simplify the source code? Like maybe converting the languages array to a map, the name to a key in the map, and mainResource to the value associated with the key that's require?

const languages = {
    bg: require('../../../../lang/main-bg')
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix that, and see if we can make this any simpler. 👍

if (BuiltinLanguages && BuiltinLanguages.setup) {
BuiltinLanguages.setup();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is order really important here? Because if order isn't really necessary, we might as well simplify this by not exporting setup from BuiltinLanguages and doing the whole initialization in BuiltinLanguages.native.js.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll explore this idea!

@saghul
Copy link
Member Author

saghul commented Jan 26, 2018

@lyubomir I simplified things a bit, PTAL. I don't think we can go full dynamic, because the React Native packager won't be able to figure out what to bundle: facebook/react-native#6391

@saghul
Copy link
Member Author

saghul commented Jan 26, 2018

Ah, wait, there is one more thing I can do! Turn those imports into requires at the map declaration phase. That works.

Load all of them as imports, so the packager includes them in the bundle. Then
register them with the i18next library.
@saghul
Copy link
Member Author

saghul commented Jan 26, 2018

@lyubomir Now! :-)

@lyubomir lyubomir merged commit 8673083 into jitsi:master Jan 26, 2018
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.

4 participants