-
Notifications
You must be signed in to change notification settings - Fork 918
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 #12442: Add ability to request any translation of a string #12443
Conversation
c7b9a81
to
fa0430a
Compare
Codecov ReportBase: 77.38% // Head: 77.52% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #12443 +/- ##
==========================================
+ Coverage 77.38% 77.52% +0.13%
==========================================
Files 147 147
Lines 7826 7834 +8
==========================================
+ Hits 6056 6073 +17
+ Misses 1770 1761 -9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely stuff - code, tests and docs all wrapped in bow 🎁
r+wc -- suggested a couple of comments to help clear the fog when we/I next dive into the code
@@ -46,6 +46,8 @@ def render_to_string(template_name, context=None, request=None, using=None, ftl_ | |||
context["fluent_l10n"] = fluent_l10n([locale, "en"], ftl_files) | |||
else: | |||
context["fluent_l10n"] = fluent_l10n([locale, "en"], settings.FLUENT_DEFAULT_FILES) | |||
|
|||
context["fluent_files"] = ftl_files or settings.FLUENT_DEFAULT_FILES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a comment here to disambiguate fluent_l10n
from fluent_files
?
@@ -128,8 +130,7 @@ def render(request, template, context=None, ftl_files=None, activation_files=Non | |||
else: | |||
context["fluent_l10n"] = fluent_l10n([locale, "en"], settings.FLUENT_DEFAULT_FILES) | |||
|
|||
# Every template gets its own .lang file, so figure out what it is | |||
# and pass it in the context | |||
context["fluent_files"] = ftl_files or settings.FLUENT_DEFAULT_FILES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a comment here to disambiguate fluent_l10n
from fluent_files
?
@@ -145,7 +145,10 @@ def inner(*args, **kwargs): | |||
# can not use += here because that mutates the original list | |||
ftl_files = ftl_files + settings.FLUENT_DEFAULT_FILES | |||
locale = kwargs.get("locale") or translation.get_language(True) | |||
l10n = fluent_l10n([locale, "en"], ftl_files) | |||
locales = [locale] | |||
if locale != "en": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if locale != "en": | |
# If we're forcing use of `en`, make sure it's in `locales`, but only once | |
if locale != "en": |
req = self.rf.get("/en-US/") | ||
req.locale = "en-US" | ||
result = render_to_string("test-fr-title.html", request=req, ftl_files="mozorg/fluent") | ||
assert result.strip() == "This is a test of the new Fluent L10n system:Title in French" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and useful to me.
No description provided.