-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Use default language when no language set #3069
Conversation
Or there is no translation for specified language
LOL, if you remove code then the coverage % goes down even though all of the code you have changed is covered! |
Good catch and thanks! |
Not indeterminate manner, but take first catched language in For now this pull create 1 additional bug in NexT theme: if 2 cases above will reproduce and Breaking Changes for most Hexo themesThis pull with 2 cases above will brake many themes in which
So, this bugfix now produce ≈ 80% breaking changes for all Hexo themes. Possible fixes for this changes
Use first language in list (instead of this) if |
On your system maybe, but the order of the language files is dependent upon the order that Node's readdir function provides. It is well documented that Node's readdir on Windows does not provide a sorted list and even on Linux the underlying readdir C function makes no promises on ordering. |
It's alphabetical or vice-versa. Will be load first or last language. But it's can't load random language, i think. So, it can't be called indeterminate manner. Anyway, default platform is Linux and as i say here, this fix for now worse then was before. |
After complete fix with language file selection in Hexo we can use old method with no bugs. Issue: hexojs/hexo#3108 Fix 1: hexojs/hexo#3069 Fix 2: hexojs/hexo#3110
After complete fix with language file selection in Hexo we can use old method with no bugs. Issue: hexojs/hexo#3108 Fix 1: hexojs/hexo#3069 Fix 2: hexojs/hexo#3110
Use default language when no language set, or there is no translation for specified language
If no language is set in _config, or the theme has no language file for the one set, then the translation data is chosen in indeterminate manner as it is taken from a list of all available translations returned by hexo.theme.i18n#list().
The changes to lib/plugins/filter/template_locals/i18n.js use i18n.languages in preference to config.language and i18n.list() as this provides an array of configured languages with 'default' on the end. This ensures that if no language is set or the language cannot be found then then default translation will be used.
The changes to test/scripts/filters/i18n_locals.js set i18n.languages rather than config.language as the original test code did not set the 'default' language correctly.
Added two tests
Both of the new tests fail on the current release but pass with the changes in the pull request.
This is a fix for #1125