dokieli icon indicating copy to clipboard operation
dokieli copied to clipboard

Apply user's preferred language to dokieli items

Open csarven opened this issue 6 years ago • 1 comments

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).

csarven avatar Aug 04 '18 11:08 csarven

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.

EurekaChen avatar Aug 05 '18 08:08 EurekaChen