linkeddata / dokieli

:bulb: dokieli is a clientside editor for decentralised article publishing, annotations and social interactions
https://dokie.li/
Other
803 stars 82 forks source link

Apply user's preferred language to dokieli items #244

Open csarven opened 6 years ago

csarven commented 6 years ago

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:

  1. 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
  2. Use document.documentElement.lang if set
  3. 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).

EurekaChen commented 6 years ago

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.