Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it i18n friendly #650

Closed
daviddias opened this issue Aug 6, 2018 · 6 comments · Fixed by #706
Closed

Make it i18n friendly #650

daviddias opened this issue Aug 6, 2018 · 6 comments · Fixed by #706

Comments

@daviddias
Copy link
Member

daviddias commented Aug 6, 2018

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

@satazor
Copy link

satazor commented Aug 6, 2018

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.

@lidel

This comment has been minimized.

@lidel
Copy link
Member

lidel commented Oct 5, 2018

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

@hacdias
Copy link
Member

hacdias commented Oct 5, 2018

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

@lidel
Copy link
Member

lidel commented Oct 9, 2018

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

@hacdias
Copy link
Member

hacdias commented Oct 9, 2018

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

@hacdias hacdias mentioned this issue Nov 22, 2018
15 tasks
@hacdias hacdias added this to the v1.0 milestone Nov 22, 2018
@hacdias hacdias mentioned this issue Nov 23, 2018
hacdias added a commit that referenced this issue Nov 23, 2018
Basically done. The locales are on `src/locales`. @lidel would you help me by setting up Transifex for IPFS Desktop? 😄 

closes #650
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants