dokieli
dokieli copied to clipboard
Apply user's preferred language to dokieli items
Depending on the DO.C.Lang
value, apply the language for all human-readable content eg. menus, common items that go into the document.
This requires all human-readable content to be moved into something like DO.C.Text
(set in src/config.js
or maybe even better set in src/i18n.js
and imported in src/config.js
) eg:
DO.C.Text = {
"SignIn": {
"en": "Sign in",
"fr": "Connexion",
"de": "Anmelden",
"zh": "登录"
}
}
Usage: DO.C.Text.SignIn[DO.C.Lang]
On DOMContentLoaded, to set DO.C.Lang
, follow this order:
- If user's preferred language is known (from their profile eg. https://github.com/linkeddata/dokieli/issues/242#issuecomment-409504926 ) - value comes from browser storage if already signed in
- Use
document.documentElement.lang
if set -
en
When user signs in, check their profile for preferred language, and if known, update DO.C.Lang
.
Provide controls to change the language (probably from the dokieli menu).
I think we should extract text from UI to separate files like .po(Portable Object File) does in other frameworks(Wordpress, Druapl,Django), we can use one json file for one language and keep config.js (or i18n.js) simple.