Fix i18n of video transcript - #3494
Conversation
There was a problem hiding this comment.
The mistake was here - defining _(item['display_name']) resulted in 'display_name' being scraped for translation, which caused obvious error 😓
So lesson learned: anything inside quotes will be scraped. So, to make sure the i18n and l10n works right here, we cannot put the dictionary lookup directly inside the _() call, instead we make it in one place and substitute it in.
There was a problem hiding this comment.
Right, and it looks quite similar to original _('{file_format}'.format(file_format=item['display_name'])?
Thank you for update.
There was a problem hiding this comment.
Ah yeah it does. the problem with the original is, again, that we have to have the quotes in there, so '{file_format}' got scraped as a string. These cases are very tricky.
There was a problem hiding this comment.
A-ha, so _('{}').format(item['display_name']) will also work?
There was a problem hiding this comment.
If you do this, then '{}' will appear in the translation file. I think it is a bad idea, to a translator seeing the string '{}' will be confusing and they very well may mis-translate it, add words, etc.
It is better to do
var = item['thing']
_(var)
because _(var) will look up the value of var in the translation file at runtime, but our static analysis scraper will not scrape anything in this call.
@auraz yikes I made a mistake on this. Take a look to understand the mistake I made.
Proof this works:
