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
Conversation
sangyuxiaowu
commented
Jul 21, 2022
•
edited
edited
- 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.
- Added traditional Chinese language and unified naming rules.
- Modified the English period in Simplified Chinese.
src/main/services/i18n/index.ts
Outdated
i18next.use(Backend).init({ | ||
fallbackLng: 'en', | ||
lng: store.preferences.get('language'), | ||
lng: lng, |
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.
No need to duplicate if prop is the same as the name of a local variable
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 get it, I tried it and it works. 😀
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.
Use just single lng
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.
Do you mean to change a variable name?
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.
{ lng: lng }
equal { lng }
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.
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.
Thanks, I see.
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.
Learned new knowledge
src/main/services/i18n/index.ts
Outdated
@@ -21,4 +21,13 @@ i18next.use(Backend).init({ | |||
} | |||
}) | |||
|
|||
// add language list 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.
I think we should remove this comment and just update https://github.com/massCodeIO/massCode/blob/master/src/main/services/i18n/locales/README.md
src/main/services/i18n/index.ts
Outdated
@@ -21,4 +21,13 @@ i18next.use(Backend).init({ | |||
} | |||
}) | |||
|
|||
// add language list here | |||
i18next.addResourceBundle('en', 'language', { |
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.
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 )
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.
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.
Did I misunderstand what you meant before? 😂
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 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.
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.
Let's keep the first option, because even without knowing the logic of i18n, it looks more logical
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.
OK, done.
My git usage is not very good, and the network with github also fluctuates. It took some time.
src/main/services/i18n/index.ts
Outdated
i18next.use(Backend).init({ | ||
fallbackLng: 'en', | ||
lng: store.preferences.get('language'), | ||
lng: lngset, |
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.
OK, I fix it myself. You need to read the basics of JS
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.
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.