ondras / my-mind

Online Mindmapping Software
https://my-mind.github.io
MIT License
3.29k stars 649 forks source link

multiple languages #89

Open zbiki opened 5 years ago

zbiki commented 5 years ago

hello ondras, which way is the best way to translate label into mymind? I would like to try a solution that can be used in mymind as an additional feature. any suggestions?

i want to translate: MM.Command.Edit = Object.create(MM.Command, { label: {value: "**Knoten bearbeiten**"}, keys: { value: [ {keyCode: 32}, {keyCode: 113} ] } });

is to create a new issue the right way for communictaion about this thinks?

mfg Christian

ondras commented 5 years ago

Hi @zbiki,

this is a rather complex topic. My Mind is, unfortunately, completely without localization support. Adding said feature is a non-trivial task.

One way to achieve this is to follow a gettext-like approach. I would start with replacing all string literals (english labels) with a call to a _ function. So the current

label: {value: "Edit item"}

would become:

label: {value: _("Edit item")}

The initial implementation of _ would be easy:

function _(key) { return key; }

Once the code is completely refactored, we can

  1. scan for all calls of _() to extract used keys,
  2. create a german version of these labels,
  3. adjust the _ function so it returns a localized value, based on the current language preference.

I am, unfortunately, out of time to implement this. I would be happy to accept it as a pull request, though.