Skip to content

Fix i18n of video transcript - #3494

Merged
sarina merged 1 commit into
masterfrom
sarina/fix-video-i18n
Apr 28, 2014
Merged

Fix i18n of video transcript#3494
sarina merged 1 commit into
masterfrom
sarina/fix-video-i18n

Conversation

@sarina

@sarina sarina commented Apr 28, 2014

Copy link
Copy Markdown
Contributor

@auraz yikes I made a mistake on this. Take a look to understand the mistake I made.

Proof this works:
screen shot 2014-04-28 at 12 31 07 pm

Comment thread lms/templates/video.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right, and it looks quite similar to original _('{file_format}'.format(file_format=item['display_name'])?
Thank you for update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A-ha, so _('{}').format(item['display_name']) will also work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

o, you right. Thanks. 👍

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