-
Notifications
You must be signed in to change notification settings - Fork 134
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
fix dayjs i18n #755
Merged
Merged
fix dayjs i18n #755
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
90e8908
fix dayjs i18n
baurine ca9be18
refine
baurine f7e6697
Merge remote-tracking branch 'origin/master' into fix-dayjs-i18n
baurine 192f3a6
Merge remote-tracking branch 'origin/master' into fix-dayjs-i18n
baurine bbcb94f
refine
baurine 7fb8c2c
fix
baurine fdde546
fix
baurine bec06e2
refine
baurine 328abbe
revert
baurine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The whole logic becomes.. zh-CN -> zh -> zh-CN now. Is it better to revert some the changes in #677? IMO it is better to leave some capability to support both zhCN and zhTW. Will it work if we fallback
zh
tozh-CN
?https://www.i18next.com/principles/fallback#fallback-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.
Tried the fallback-language setting, it's a bit troublesome, you need to cover many languages, for example:
According to some documents, the languages are also maybe:
(Although I don't meet)
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 maybe we can fix this bug first. Then later if someone contributes the traditional Chinese translation for us, we can add the support for dayjs.
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.
This fallback looks to be stupid. Why can't we just fallback zh to zh-CN?
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.
Not sure whether
zh -> zh-CN
will makezh-TW
fallback tozh-CN
, let me have a try.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.
Tried to revert it and use the following setting for i18next:
It works in most cases, except when you run the dashboard for the first time with another language likes
zh-TW
.Because we don't import zh-tw locale for dayjs, and i18next's fallback doesn't affect dayjs.
But it will always works fine after manually selecting the 'zh-CN' or '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.
I also tried this:
It works when language is
zh
, but crashes whenen
, I think the dayjs has bug (will check it later).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.
Seems to find a good way:
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 the real problem that #677 need to solve is that, the initial language is the detected language, instead of the effective language. So that by assigning the detected language it may not be a useful 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.
So you mean we need write a util method
getEffectiveLang()
and use its value as Select component's default value, right?I tried it and works fine. We don't need to revert the zh.yml to zh-CN.yml, and we shouldn't, else 'zh-TW' will fallback to 'en' translation instead of 'zh' translation.