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 #12442: Add ability to request any translation of a string #12443

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

pmac
Copy link
Member

@pmac pmac commented Dec 2, 2022

No description provided.

@pmac pmac force-pushed the fluent-english-strings branch from c7b9a81 to fa0430a Compare December 6, 2022 17:21
@pmac pmac marked this pull request as ready for review December 6, 2022 17:23
@pmac pmac requested review from robhudson and stevejalim December 6, 2022 17:29
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Base: 77.38% // Head: 77.52% // Increases project coverage by +0.13% 🎉

Coverage data is based on head (fa0430a) compared to base (b08d42c).
Patch coverage: 100.00% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
lib/l10n_utils/__init__.py 94.07% <100.00%> (+6.07%) ⬆️
lib/l10n_utils/fluent.py 95.15% <100.00%> (+0.08%) ⬆️
lib/l10n_utils/templatetags/fluent.py 94.44% <100.00%> (+1.11%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@stevejalim stevejalim left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@robhudson robhudson left a 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.

@stevejalim stevejalim merged commit 9e8b38e into mozilla:main Dec 7, 2022
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