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

CLI utility to check coverage of a locale #1742

Closed
1 task done
yookoala opened this issue Apr 14, 2017 · 10 comments
Closed
1 task done

CLI utility to check coverage of a locale #1742

yookoala opened this issue Apr 14, 2017 · 10 comments
Labels
i18n Internationalization and localization

Comments

@yookoala
Copy link
Contributor

yookoala commented Apr 14, 2017

It is currently quite hard to keep track on the translations. Strings spread across source code of Ruby and Javascript. It is hard for a translator to tell if a language translation is completed.

I propose we can add some CLI utility that will compare a given locale with the English (presume the English translation file is complete coverage). Then translator can have a reference how complete their work is.

I am willing to write such tool. But what language should I use? Ruby or Nodejs?

Also, where should I put such script?


  • I searched or browsed the repo’s other issues to ensure this is not a duplicate.
@mjankowski
Copy link
Contributor

Running i18n-tasks health gets some of this.

@Gargron
Copy link
Member

Gargron commented Apr 14, 2017

i18n-tasks health is for this, although it only deals with Ruby localizations. The react-intl story is more complex. There are packages that are supposed to make managing translations easier, but they do not work with Browserify, or at least I could not get them to work. So it's connected to #1712

@wxcafe wxcafe added enhancement i18n Internationalization and localization labels Apr 15, 2017
@ghost
Copy link

ghost commented Apr 16, 2017

The guides should mention the tools that are available for this. I'm having a hell of a time keeping the translation up to date. Things are not only being added, but they are also being changed. I'm able to catch all the additions so far by using a YAML merge tool I found, but I'm missing out on any changes to existing strings, which can be a huge problem. Does the Ruby tool you mention deal with changes? I'm thinking it can't really be solved unless a diff can be performed against different commits of the *en.yml files to check for that.

@ghost
Copy link

ghost commented Apr 16, 2017

As for JSX I'm temporarily converting the files to JSON and using a JSON merge tool on them to catch new strings from the English version. However, this will, as with the YAML merge, overwrite changes to existing strings with old localized strings.

Some kind of 3-way merge with Git commit IDs is needed.

Proposed algorithm:

  1. Compare old and new versions of the English locale files.
  2. Produce new localized files that include new strings from the English files, but not any strings now missing from the English files. (Takes care of simple additions and removals.)
  3. Find any changed strings in the English files and overwrite those to the localized files. (Takes care of updated strings.)
  4. Produce a report of these changes.
  5. Translator can now review and edit the localized files in a text editor.

@ghost
Copy link

ghost commented Apr 16, 2017

The YAML is probably easy to parse. The JSX files are a problem. Why not use YAML? I mean, I'm sure there are 934895834 YAML parsers that could run in a browser at this point.

@ghost
Copy link

ghost commented Apr 16, 2017

(JSON is another possibility, but the syntax is strict, and no comments are allowed.)

@yookoala
Copy link
Contributor Author

browserify, and hence browserify_rails does not have ability to support bundling files other than js.

If we were to use YAML in javascript translations, I think we need to use rollup.js or webpack. They both have plugins to extend functionality beyond JS bundling. And I found YAML support in both cases. If things goes well, we may simply import those YAML files and have the bundler do the translations.

Rollup.js is a new bundler and has a much easy config to work with. Webpack is much older and hence more available plugins for other future development.

YAML support for rollup.js

YAML support for webpack

@ghost
Copy link

ghost commented May 1, 2017

Working on something here: https://github.com/thor-the-norseman/mastotran

@mjankowski
Copy link
Contributor

FYI, there is a WIP branch here which is moving to webpack, which will impact how i18n works.

@Gargron
Copy link
Member

Gargron commented Jun 29, 2017

  1. i18n-tasks health for YAML
  2. yarn run manage:translations for JS

@Gargron Gargron closed this as completed Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n Internationalization and localization
Projects
None yet
Development

No branches or pull requests

4 participants