lvgl / lv_i18n

Internationalization (i18n) for LVGL
MIT License
57 stars 17 forks source link

Change local #22

Closed kisvegabor closed 5 years ago

kisvegabor commented 5 years ago

Hi,

I've created two languages in two yaml file:

  1. English
  2. Magyar (mean Hungarian)

I've used the long names because this way I can easily see all the existing languages and create a list from them.

I've tried to compile with -l 'English' option but got this error:

/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lv_i18n.js:17
  throw err;
  ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at renameKeys (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/plurals.js:22:10)
    at module.exports.create_c_plural_fn (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/plurals.js:85:20)
    at lang_template (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/compiler_template.js:79:3)
    at locales.map.l (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/compiler_template.js:95:20)
    at Array.map (<anonymous>)
    at module.exports (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/compiler_template.js:95:11)
    at Object.module.exports.execute (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/cmd_compile.js:143:13)
    at Object.module.exports.run (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lib/cli.js:47:64)
    at Object.<anonymous> (/home/kisvegabor/.nvm/versions/node/v11.2.0/lib/node_modules/lv_i18n/lv_i18n.js:8:24)

I've attached two files to reproduce: lv_i18n_test.zip

puzrin commented 5 years ago

You should use valid locale names (shorten or full), because in other case script does not know how to pick proper pluralizer & forms.

kisvegabor commented 5 years ago

I see, thank you. Where can I find the list of "proper names"?

puzrin commented 5 years ago

I'd try "locale names" in google. Don't remember "official" source.

First result, for example https://www.science.co.il/language/Locale-codes.php.

puzrin commented 5 years ago

Can this be closed?

I could try more strict checks and show more descriptive error for unknown locales. In theory, custom locales are used sometime for specific slang translations. But IMO that's not needed in real world for embedded. And that's certainly should not be used as main approach.

kisvegabor commented 5 years ago

I found it important to simply enumerate the language on their own language (e.g. "Magyar" instead of "Hungarian" or "hu"). Now I've created an array to map hu->Magyar, en-GB->English. It works this way, so this issue can be closed.