Add i18n translation 'zh-CN' #13
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/i18n"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Trying to add i18n style multi-language support and I tranlated 'zh-CN'. English is displayed by default if no supported language file.
And added a language select in Settings page. It follows the language preset of the browser/system by default.
And I added a new entry for previewing UI locally in 'Makefile':
make ui-preview.To add other language, just add a new JS file in 'src/i18n/' directory and add a new option in the settings page.
And I though about splitting the language file out from 'ui.html', but it's too complecated, I think.
All the changes are front-end side.
Reviewed and merging. Verified locally: sentinel
"__I18N_DICTIONARIES__";is injected exactly once,sed rsplices eachsrc/i18n/*.jsfile after it, sentinel line then deleted; post-build_ui_tmp.htmlcontains onewindow.GARLIC_I18N = {}init followed by thewindow.GARLIC_I18N[zh-CN] = { ... }dict.t()usestextContent(no XSS),esc()wraps<option>values/labels. Language preference persisted inlocalStorageundergarlic_lang,systemfallback vianavigator.languages.One minor nit for a follow-up (not blocking):
ui-previewbindspython3 -m http.serverto0.0.0.0— for a local preview127.0.0.1would be safer on shared networks.