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

Add changes command #55

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

dadaxl
Copy link

@dadaxl dadaxl commented Jun 24, 2019

With using the syntax
ember l10n:changes
its possible to check if new Message Items are added in the Application in order to review them before they get manifested via
ember l10n:extract

The CL Output could be improved and it needs to be checked if the comparison check works for all possible scenarios.

Copy link
Contributor

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! I added small comments to illustrate, and made commit some changes to the PR.
It is mainly based around some trickier parts of the gettext format (message context), which was previously ignored. I ran it against a large app of ours, and it seems to work pretty good now! Thank you for the PR!

* @param {*} options
*/
_compareWithPoFile(options) {
let poFile = `${options.extractTo}/${options.language}.po`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the .pot file here (e.g options.potName --> messages.pot by default), as that might be different from the en.po, and can be considered the baseline :)

if (this.fileExists_(poFile)) {
let poData = fs.readFileSync(poFile);
let jsonData = parser.po.parse(poData);
let existingTranslations = jsonData.translations[''];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The '' property are the default translations without a context. There can also be translations with a context, which would be namespaced by context. e.g.:

  translations: {
    '': {...},
    'my context 1': {...}
  }
}

So we should probably loop over this, e.g. Object.keys(jsonData.translations).forEach((namespace) => {...}).

@mydea
Copy link
Contributor

mydea commented Jun 25, 2019

Note sure why the tests are not passing, linting looks fine locally... I'll investigate!

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 this pull request may close these issues.

2 participants