-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
lib/commands/changes.js
Outdated
* @param {*} options | ||
*/ | ||
_compareWithPoFile(options) { | ||
let poFile = `${options.extractTo}/${options.language}.po`; |
There was a problem hiding this comment.
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 :)
lib/commands/changes.js
Outdated
if (this.fileExists_(poFile)) { | ||
let poData = fs.readFileSync(poFile); | ||
let jsonData = parser.po.parse(poData); | ||
let existingTranslations = jsonData.translations['']; |
There was a problem hiding this comment.
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) => {...})
.
Note sure why the tests are not passing, linting looks fine locally... I'll investigate! |
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.