Skip to content
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

Fix i18n of video transcript #3494

Merged
merged 1 commit into from
Apr 28, 2014
Merged

Fix i18n of video transcript #3494

merged 1 commit into from
Apr 28, 2014

Conversation

sarina
Copy link
Contributor

@sarina sarina commented Apr 28, 2014

@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

<a class="a11y-menu-item-link" href="#${item['value']}" title="${_(item['display_name'])}" data-value="${item['value']}">
${_(item['display_name'])}
<% dname = item['display_name'] %>
<a class="a11y-menu-item-link" href="#${item['value']}" title="${_(dname)}" data-value="${item['value']}">
Copy link
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
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
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
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
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
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