Netlify-cms: Translation

Created on 9 Nov 2017  ·  20Comments  ·  Source: netlify/netlify-cms

- Do you want to request a feature or report a bug?
feature

- What is the current behavior?
the cms is only in english
- If the current behavior is a bug, please provide the steps to reproduce.

- What is the expected behavior?
it might be possible to select the default language in Netlify and also be able to change it in CMS.
- Please mention your CMS, node.js, and operating system version.

feature pinned

Most helpful comment

@nahueld Any updates on this or work being done? Would like to contribute if needed.

All 20 comments

We currently have a PR for supporting other languages: https://github.com/netlify/netlify-cms/pull/403. It needs finished up, though (https://github.com/netlify/netlify-cms/pull/403#issuecomment-326753066) and if you are able to help, that would be great!

This will be closed by #974.

Given that #974 is closed, would you like me to work on this? I can start a new PR following the previous findings. Im interested in getting this in.

@nahueld if you need some help, you can count with me.
I think you can start a new branch with frozen features to work only with translatation feature... We can discuss the patterns before putting our hands dirty.

Based on what I have read so far the solution that I have in mind would be implemented in 2 phases:

1️⃣ Extract current texts from core

This phase would encompass the following (but not limited to) tasks:

  • Create a key/value file for all the texts in core module.

    • Key would be a meaningful label to identify the text.

    • The value would be the actual translation (or in this phase the English text)

  • Create a mechanism to read/use these values (probably using Polyglot, but open to other suggestions)

2️⃣ Provide a mechanism to provide a custom key/value file

  • In this 2nd phase we would allow users to pass a custom key/value file.
  • We would need to document the expected keys.
  • Under the hood we would merge both files (defaulting to English texts if some of the keys are not provided by the user).
  • Probably the file path would be provided as value in the config.yml.

Future improvements (not necessarily part of this).

  • Allow users to provide multiple translation files.
  • Read browser agent language and decide which one to use.
  • Include some good translations as part of the default build.

Let me know your thoughts.

@nahueld I agree with all your suggestions!
could you lead this with a new fork only for this feature?
if you start this, i can help you committing too.

we can use gatsby-plugin-i18n on cms

@derevandal The CMS is not built on Gatsby -- only our docs site -- so I'm not sure that a Gatsby plugin would work. Thanks for both of your work on this!

Would love seeing this feature. I use the CMS mostly in German environments. So currently there is a mix between the content models having German labels, but the CMS itself showing everything in English.

At least some kind of translation functionality would be nice. Doesn't need to be switchable by the CMS user for a MVP in my opinion.

I have a need/use case for this too. I have a multilingual site, and I'd like to see Netlify CMS not sticking out like a sore thumb because it's not translated.

I'm new to Netlify CMS but I had a look at the source and I was wondering what would be the best way to implement this.

The hardest part seems to have already been implemented. That is, extract strings from the code and keep them somewhere in a key/value format. From glancing the code, I guess these are the strings.

Unfortunately, there doesn't seem to be a way to override them, as the language is hardcoded to en.

So, am I right in assuming we need two things:

  • This line should set the locale to whatever's in the config file, or default to en
  • We need a way to inject an object to replace the i18n key/values object or/and (my preference) make getPhrases() take a locale/language parameter as set in the config, so it can load one of the supported languages.

The latter would mean that translations ship with Netlify CMS, and thus language updates/fixes would be tied to releases. That doesn't seem like a problem to me, but what do I know.

Speaking of which, I might be way off here. But I think it's an important feature, and would be a nice feather in the Netlify CMS cap to support a bunch of languages out of the box. So can we do this?

Definitely doable! @nahueld, who implemented the hardest part as you mentioned, laid out the plan in his comment: https://github.com/netlify/netlify-cms/issues/789#issuecomment-417174441

(specifically phase two.)

All right lets get phase 2 working so people can contribute with more pretentious features

@nahueld clarifying - are you working on this yourself?

Yes will try to have something in a week , we can discuss other approaches
but currently is similar to how we load the config file

On Thu, 28 Feb 2019, 13:39 Shawn Erquhart, notifications@github.com wrote:

@nahueld https://github.com/nahueld clarifying - are you working on
this yourself?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/netlify/netlify-cms/issues/789#issuecomment-468343543,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AApFF9Pt4CG0Qez9nGCuRLrJeKilQyiaks5vSAZGgaJpZM4QYpD9
.

Sounds good. I'd like to provide built in translations that can be used based on browser locale, that would be worth some additional kbs.

I would rather have that configurable, since I will know the language of the editors on my pages in advance. Plus this will only be one language. So having all translation for many different languages available but completely unused doesn't justify these additional kbs in my opinion. But ymmv, of course.

@nahueld Any updates on this or work being done? Would like to contribute if needed.

Any updates on this? I've seen @nahueld already started working on this in https://github.com/nahueld/netlify-cms/commit/abd6ced25b3500e602c460aab3d52677e4123715

How can we help?

If anyone wants to contribute please do! The plan is here: https://github.com/netlify/netlify-cms/issues/789#issuecomment-417174441, but it should also be stated that we don't want to hardcode all languages, they should be registered as extensions. So a bit of API architecture thinking will be required.

Looking forward to this! I would join the translation when #2528 lands

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings