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

Change how duplicate values are stored and add Chinese Traditional for i18n #161

Merged
merged 4 commits into from Jul 22, 2022
Merged

Conversation

sangyuxiaowu
Copy link
Contributor

@sangyuxiaowu sangyuxiaowu commented Jul 21, 2022

  1. Place the name of the language separately at index.ts so that friends who add new languages can modify only one place and do not modify other localization files.
  2. Added traditional Chinese language and unified naming rules.
  3. Modified the English period in Simplified Chinese.

i18next.use(Backend).init({
fallbackLng: 'en',
lng: store.preferences.get('language'),
lng: lng,
Copy link
Member

Choose a reason for hiding this comment

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

No need to duplicate if prop is the same as the name of a local variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get it, I tried it and it works. 😀

Copy link
Member

Choose a reason for hiding this comment

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

Use just single lng

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to change a variable name?

Copy link
Member

Choose a reason for hiding this comment

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

{ lng: lng } equal { lng }

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Learned new knowledge

@@ -21,4 +21,13 @@ i18next.use(Backend).init({
}
})

// add language list here
Copy link
Member

Choose a reason for hiding this comment

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

@@ -21,4 +21,13 @@ i18next.use(Backend).init({
}
})

// add language list here
i18next.addResourceBundle('en', 'language', {
Copy link
Member

Choose a reason for hiding this comment

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

In general, the previous solution looked logical, although the current one works, since it will just be a fallback to en. I do not even know what is more correct )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm guessing this is because of the alternate mechanism.
This is handled by mapping, only "en" has this value, so just use it?
Maybe change it to something else and it will work fine.

Reminds me of a comic: it works fine, don't modify it.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did I misunderstand what you meant before? 😂

Copy link
Member

Choose a reason for hiding this comment

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

I know exactly why it works, because there is a fallback to en if the selected locale has either no translation or no property at all.

I'm just confused which option to leave just. Because they both work.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the first option, because even without knowing the logic of i18n, it looks more logical

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, done.
My git usage is not very good, and the network with github also fluctuates. It took some time.

i18next.use(Backend).init({
fallbackLng: 'en',
lng: store.preferences.get('language'),
lng: lngset,
Copy link
Member

Choose a reason for hiding this comment

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

OK, I fix it myself. You need to read the basics of JS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see. so awkward. I thought it was for code specification and to prevent ambiguity, so I changed the variable name.
I believe that participating in the project can learn a lot, please bear with me.

@antonreshetov antonreshetov merged commit 8b00fcd into massCodeIO:master Jul 22, 2022
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

2 participants