Commit fc16ee3a by Ned Batchelder

Tweaks for i18n docs

parent fba7bb91
...@@ -187,6 +187,10 @@ native Coffeescript features that break the extraction from the .js files: ...@@ -187,6 +187,10 @@ native Coffeescript features that break the extraction from the .js files:
# Translators: this won't get to the translators! # Translators: this won't get to the translators!
message = gettext("Welcome, #{student_name}!") # This won't work! message = gettext("Welcome, #{student_name}!") # This won't work!
# YES like this:
`// Translators: this will get to the translators.`
message = gettext("This works")
### ###
Translators: This will work, but takes three lines :( Translators: This will work, but takes three lines :(
### ###
...@@ -425,6 +429,11 @@ which is now invalid Javascript. This can be avoided by using double-quotes ...@@ -425,6 +429,11 @@ which is now invalid Javascript. This can be avoided by using double-quotes
for the Javascript string. The better solution is to use a filtering function for the Javascript string. The better solution is to use a filtering function
that properly escapes the string for Javascript use:: that properly escapes the string for Javascript use::
<%!
from django.utils.translation import ugettext as _
from django.utils.html import escapejs
%>
...
<script> <script>
var feeling = '${escapejs(_("I love you."))}'; var feeling = '${escapejs(_("I love you."))}';
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment