-
-
Notifications
You must be signed in to change notification settings - Fork 832
Fix bug with gen-i18n/js when adding new plurals #1521
Conversation
scripts/gen-i18n.js
Outdated
@@ -177,7 +177,9 @@ const trObj = {}; | |||
for (const tr of translatables) { | |||
trObj[tr] = tr; | |||
if (tr.includes("|")) { | |||
trObj[tr] = inputTranslationsRaw[tr]; | |||
if (inputTranslationsRaw[tr]) { |
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.
Maybe &&
?
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.
Fair :)
@@ -177,7 +177,9 @@ const trObj = {}; | |||
for (const tr of translatables) { | |||
trObj[tr] = tr; |
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.
Perhaps explicitly check that tr
is not undefined, to avoid future problems?
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.
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.
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.
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.
Re-run gen-i18n after fixing #1521
No description provided.