Skip to content

Don't scrape unnecessary strings for i18n - #3438

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

Don't scrape unnecessary strings for i18n#3438
sarina merged 1 commit into
masterfrom
sarina/fix-video-i18n

Conversation

@sarina

@sarina sarina commented Apr 23, 2014

Copy link
Copy Markdown
Contributor

@auraz can you take a look at this?

@auraz

auraz commented Apr 23, 2014

Copy link
Copy Markdown
Contributor

Result is:

#: lms/templates/video.html:128 lms/templates/video.html:129
msgid "display_name"
msgstr ""

What should be translated: values

    transcript_download_format = String(
        help="Transcript file format to download by user.",
        scope=Scope.preferences,
        values=[
            {"display_name": "SubRip (.srt) file", "value": "srt"},
            {"display_name": "Text (.txt) file", "value": "txt"}
        ],
        default='srt',
    )

So as they are not translated, I think internationalization may be removed from line 128 at all.
And added to {"display_name": _("SubRip (.srt) file"), "value": "srt"},
Right?
Thank you for catching this.

@sarina

sarina commented Apr 23, 2014

Copy link
Copy Markdown
Contributor Author

Hmm. Unfortunately we don't yet have a way to do i18n for XModule fields (this is defined in 'common/lib/xmodule/xmodule/video_module/video_xfields.py' yes?)

We could do something fancy for this particular file though, if the display_names in common/lib/xmodule/xmodule/video_module/video_xfields.py are shown in the LMS. Let me know and I can code something up for you to look at.

@auraz

auraz commented Apr 23, 2014

Copy link
Copy Markdown
Contributor

@sarina: "this is defined in 'common/lib/xmodule/xmodule/video_module/video_xfields.py' yes?"
yes

@auraz

auraz commented Apr 23, 2014

Copy link
Copy Markdown
Contributor

Yes, those values, from transcript_download_format are shown in LMS.
For clarification: It is not allowed for now to write :"display_name": _("SubRip (.srt) file")?

@sarina

sarina commented Apr 25, 2014

Copy link
Copy Markdown
Contributor Author

@auraz yes, that is the case, see https://edx-wiki.atlassian.net/browse/LMS-2078

However there is a workaround, see what I've done in this PR. What I did was in the video_xfields.py, define a dummy _ so that the strings can be successfully scraped. Then, in lms/templates/video.html, we call _() on a value which is a string, and because we've got the scraped strings, the localized string can be presented. Does that make sense?

@sarina

sarina commented Apr 28, 2014

Copy link
Copy Markdown
Contributor Author

@auraz this is ready for a second look, please

@auraz

auraz commented Apr 28, 2014

Copy link
Copy Markdown
Contributor

thanks for explanation. 👍

@sarina

sarina commented Apr 28, 2014

Copy link
Copy Markdown
Contributor Author

Use this pattern if you have need to i18n more things from Fields. And don't hesitate to ask me if you encounter any weird issues and need clarification.

@auraz

auraz commented Apr 28, 2014

Copy link
Copy Markdown
Contributor

OK, thanks!

sarina added a commit that referenced this pull request Apr 28, 2014
Don't scrape unnecessary strings for i18n
@sarina
sarina merged commit 7a51382 into master Apr 28, 2014
@sarina
sarina deleted the sarina/fix-video-i18n branch April 28, 2014 14:45
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.

3 participants