Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix bug with gen-i18n/js when adding new plurals #1521

Merged
merged 2 commits into from
Oct 24, 2017
Merged

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Oct 23, 2017

No description provided.

@@ -177,7 +177,9 @@ const trObj = {};
for (const tr of translatables) {
trObj[tr] = tr;
if (tr.includes("|")) {
trObj[tr] = inputTranslationsRaw[tr];
if (inputTranslationsRaw[tr]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe &&?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair :)

@@ -177,7 +177,9 @@ const trObj = {};
for (const tr of translatables) {
trObj[tr] = tr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps explicitly check that tr is not undefined, to avoid future problems?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, not having an entry in inputTranslations is a legitimate situation. If translatables contains undefined, something's gone very screwy and if we were worried about this, I'd rather check it before it comes out of the function that screwed it up.

Copy link
Contributor

@pafcu pafcu Oct 24, 2017

Choose a reason for hiding this comment

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

True, but then you have to check it in multiple places rather than just here. AFAICT translatables includes the strings from the .js files, so if you have undefined here you definitely have a problem, and can throw an error in a fool-proof way. At least you know you have a problem, even if you don't know what caused it.

Compare with checking all the various branches where you add strings, which makes it possible to figure out what went wrong, but it's also possible to miss/forget checking in some situation. Just thinking about how much effort should be spent on polishing this, when a generic error is probably helpful enough.

@dbkr dbkr assigned dbkr and lukebarnard1 and unassigned lukebarnard1 and dbkr Oct 24, 2017
@dbkr dbkr merged commit 93fca84 into develop Oct 24, 2017
dbkr added a commit that referenced this pull request Oct 24, 2017
dbkr added a commit that referenced this pull request Oct 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants