Mark strings in javascript for translation.
Review Request #4453 — Created Aug. 13, 2013 and submitted
Mark strings in javascript for translation. Django provides a nice, gettext-like API for localizing strings in javascript files. Now that we've integrated the jsi18n view, we can mark these strings so that people can translate them. The only unfortunate thing about this is that there's no good way to wrap strings and have them concatenate (like there is with python or C), so for longer strings that we want to localize, they have to be all together on one line.
- Extracted messages and saw that djangojs.po had all the expected strings. - Added some fake italian and chinese versions of the "An issue was opened" string and saw that when my browser was set to prefer those languages, I saw the translated string. - Ran js-tests.
Description | From | Last Updated |
---|---|---|
You can (or should be able to) do: <%- gettext('...') %> instead. Assuming xgettext sees that. Assuming we do need … |
chipx86 |
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: reviewboard/settings.py reviewboard/urls.py Ignored Files: reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftResourceModelMixin.js reviewboard/static/rb/js/views/reviewRequestEditorView.js .gitignore reviewboard/static/rb/js/views/issueSummaryTableView.js reviewboard/static/rb/js/models/reviewRequestEditorModel.js reviewboard/static/rb/js/views/commentDialogView.js reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js reviewboard/static/rb/js/resources/models/diffModel.js reviewboard/static/rb/js/views/commentIssueBarView.js reviewboard/static/rb/js/views/dndUploaderView.js reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/reviewDialogView.js reviewboard/static/rb/js/newReviewRequest/views/repositorySelectionView.js reviewboard/static/rb/js/views/abstractCommentBlockView.js reviewboard/static/rb/js/newReviewRequest/views/newReviewRequestView.js reviewboard/static/rb/js/newReviewRequest/models/preCommitModel.js reviewboard/static/rb/js/newReviewRequest/views/postCommitView.js reviewboard/static/rb/js/utils/apiUtils.js reviewboard/static/rb/js/newReviewRequest/views/preCommitView.js reviewboard/static/rb/js/resources/models/draftReviewRequestModel.js reviewboard/static/rb/js/models/commentEditorModel.js reviewboard/static/rb/js/pages/views/reviewablePageView.js reviewboard/static/rb/js/repositoryform.js reviewboard/templates/base.html reviewboard/static/rb/js/common.js
-
Shame underscore uses _. I see that Mozilla seems to use __, but I don't know that we have that level of control, due to makemessages calling xgettext on our behalf. Also a shame that gettext doesn't know about string concatenation here. Hm. Looks like there's a patch out there for factoring in + for Python from April of this year, but no idea if it made it in, or if we'll ever get to use it for JavaScript. Oh well.
-
You can (or should be able to) do: <%- gettext('...') %> instead. Assuming xgettext sees that. Assuming we do need to escape content (I don't know what gettext for JavaScript is guaranteed to return HTML-safe content or not), the <%- will escape for us. Otherwise, <%= Same with all other sites.
- Diff:
-
Revision 2 (+203 -165)
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: Ignored Files: reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftResourceModelMixin.js reviewboard/static/rb/js/views/reviewRequestEditorView.js reviewboard/static/rb/js/views/issueSummaryTableView.js reviewboard/static/rb/js/models/reviewRequestEditorModel.js reviewboard/static/rb/js/views/commentDialogView.js reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js reviewboard/static/rb/js/resources/models/diffModel.js reviewboard/static/rb/js/views/commentIssueBarView.js reviewboard/static/rb/js/views/dndUploaderView.js reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/reviewDialogView.js reviewboard/static/rb/js/newReviewRequest/views/repositorySelectionView.js reviewboard/static/rb/js/views/abstractCommentBlockView.js reviewboard/static/rb/js/newReviewRequest/views/newReviewRequestView.js reviewboard/static/rb/js/newReviewRequest/models/preCommitModel.js reviewboard/static/rb/js/newReviewRequest/views/postCommitView.js reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js reviewboard/static/rb/js/utils/apiUtils.js reviewboard/static/rb/js/newReviewRequest/views/preCommitView.js reviewboard/static/rb/js/resources/models/draftReviewRequestModel.js reviewboard/static/rb/js/models/commentEditorModel.js reviewboard/static/rb/js/pages/views/reviewablePageView.js reviewboard/static/rb/js/repositoryform.js reviewboard/static/rb/js/common.js reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: Ignored Files: reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftResourceModelMixin.js reviewboard/static/rb/js/views/reviewRequestEditorView.js reviewboard/static/rb/js/views/issueSummaryTableView.js reviewboard/static/rb/js/models/reviewRequestEditorModel.js reviewboard/static/rb/js/views/commentDialogView.js reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js reviewboard/static/rb/js/resources/models/diffModel.js reviewboard/static/rb/js/views/commentIssueBarView.js reviewboard/static/rb/js/views/dndUploaderView.js reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/reviewDialogView.js reviewboard/static/rb/js/newReviewRequest/views/repositorySelectionView.js reviewboard/static/rb/js/views/abstractCommentBlockView.js reviewboard/static/rb/js/newReviewRequest/views/newReviewRequestView.js reviewboard/static/rb/js/newReviewRequest/models/preCommitModel.js reviewboard/static/rb/js/newReviewRequest/views/postCommitView.js reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js reviewboard/static/rb/js/utils/apiUtils.js reviewboard/static/rb/js/newReviewRequest/views/preCommitView.js reviewboard/static/rb/js/resources/models/draftReviewRequestModel.js reviewboard/static/rb/js/models/commentEditorModel.js reviewboard/static/rb/js/pages/views/reviewablePageView.js reviewboard/static/rb/js/repositoryform.js reviewboard/static/rb/js/common.js reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js