Ipfs-desktop: Make it i18n friendly

Created on 6 Aug 2018  路  6Comments  路  Source: ipfs-shipyard/ipfs-desktop

@satazor implemented this for js.ipfs.io using react-intl and it is super easy to work with. @satazor, wanna shine some light here?

All 6 comments

Yes we used react-intl in js.ipfs.io mainly because it's made for react and supports:

  • messages with placeholders
  • date & time
  • relative dates (xxx ago)
  • number formatting, including currency

The strategy we went for was to have a intl folder that containes everything related to i18n. Contributors just need to follow a few steps to add a new language, which are detailed in the README.

Note that ideally, you would lazy load the locale files. More specifically, you should only call addLocaleData when a language is requested. Moreover, if you use nested messages for readability, be sure to flat the messages object because nesting is not supported. You may use https://github.com/IonicaBizau/obj-flatten to flatten the messages.

I think that's all, feel free to ask more questions and I will happily provide help.

cc https://github.com/ipfs/ipfs-gui/issues/50 (Meta: Translation Project for IPFS GUIs)

Some relevant notes: https://github.com/ipfs/i18n#adding-i18n-to-your-project
Good prior art can be found in WebUI.
I think we won't have a lot of string in revamped version.
As soon initial UI lands, may be a good idea to prioritize i18n and do it sooner than later, that way translation team will have more time to work on it before shipping :)

I can add it on the PR I'm working on. It's not that much 馃槃

@hacdias as long the change set is not too big.

(Would be cool to have it in separate PR, so we can link to it as an example for other projects that want to add i18n)

@lidel it would probably introduce a lot of changes to the code I wrote so far, but basically just adding translation functions. We can leave it for another PR just to keep things separated. #662 is already getting really big, but it couldn't be other way since it introduces really deep changes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nlko picture nlko  路  3Comments

hacdias picture hacdias  路  6Comments

NatoBoram picture NatoBoram  路  3Comments

dignifiedquire picture dignifiedquire  路  4Comments

lidel picture lidel  路  5Comments