Skip to content

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

Merged
antonreshetov merged 4 commits intomassCodeIO:masterfrom
sangyuxiaowu:master
Jul 22, 2022
Merged

Change how duplicate values are stored and add Chinese Traditional for i18n#161
antonreshetov merged 4 commits intomassCodeIO:masterfrom
sangyuxiaowu:master

Conversation

@sangyuxiaowu
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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

}
})

// add language list here
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

})

// add language list here
i18next.addResourceBundle('en', 'language', {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants