Skip to content

Update to moz.l10n 0.13, migrating all Fluent messages with selectors - #4351

Merged
eemeli merged 3 commits into
mozilla:mainfrom
eemeli:moz-l10n-update
Jul 29, 2026
Merged

eemeli merged 3 commits into
mozilla:mainfrom
eemeli:moz-l10n-update

Conversation

@eemeli

@eemeli eemeli commented Jul 28, 2026

Copy link
Copy Markdown
Member

Fixes #4230

@eemeli
eemeli requested a review from mathjazz July 28, 2026 15:33
@flodolo flodolo changed the title Update to moz.l10n 0.13, mirgating all Fluent messages with selectors Update to moz.l10n 0.13, migrating all Fluent messages with selectors Jul 28, 2026
@mathjazz

Copy link
Copy Markdown
Collaborator

The tests are failing.

@codecov-commenter

codecov-commenter commented Jul 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.53%. Comparing base (bd098e9) to head (1447474).
⚠️ Report is 2 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left a few comments in the migration, the rest looks good.

Also, do the following messages not need a migration?

platform-note = Platform: { PLATFORM() }
item-count = { NUMBER($n) } items

for e in value_entities:
msg = fluent_parse_entry(e.string)
e.value = message_to_json(msg.value)
Entity.objects.bulk_update(value_entities, ["value"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worth adding batch_size here in line 36, too? If not else for 3rd party users.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Eh, the actual entity counts here will all fit into a single batch, but there's no harm either.

Comment on lines +15 to +20
# The `?` JSON operator is not directly supported by Django
value_entities = Entity.objects.raw("""
SELECT * FROM base_entity e
JOIN base_resource r ON r.id = e.resource_id
WHERE r.format = 'fluent' AND e.value ? 'decl'
""")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's has_key:

Suggested change
# The `?` JSON operator is not directly supported by Django
value_entities = Entity.objects.raw("""
SELECT * FROM base_entity e
JOIN base_resource r ON r.id = e.resource_id
WHERE r.format = 'fluent' AND e.value ? 'decl'
""")
Entity.objects.filter(resource__format="fluent", value__has_key="decl").

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I'd missed that.


operations = [
migrations.RunPython(
reparse_multi_pattern_fluent, reverse_code=reparse_multi_pattern_fluent

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any chance 0.12 can load the 0.13-shaped JSON?

Then a code-only rollback is safe without touching the data and we can use migrations.RunPython.noop for the reverse migration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

moz-l10n 0.12 is fine loading messages parsed by 0.13, but it'll serialize them wrong -- we'll get NUMBER() wrappers in every select message. So if this needs a rollback, it does need to be run with moz-l10n 0.12.

@eemeli
eemeli requested a review from mathjazz July 29, 2026 15:44
@mathjazz

Copy link
Copy Markdown
Collaborator

Thanks.

Could you please address this one?

Also, do the following messages not need a migration?

platform-note = Platform: { PLATFORM() }
item-count = { NUMBER($n) } items

@eemeli

eemeli commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Thanks.

Could you please address this one?

Also, do the following messages not need a migration?

platform-note = Platform: { PLATFORM() }
item-count = { NUMBER($n) } items

Ah, sorry for missing that! Such messages don't need a migration because they don't exist in any active message. We never use PLATFORM() as a formatting function, and we never use a NUMBER() with no named options. For NUMBER() with options, we handle their serialization the same as before. For any translations that have added an unnecessary NUMBER() wrapper, that'll now get dropped during serialization.

Or is your concern about non-Mozilla Pontoon users? If so, then we're going to need to make the migration quite a bit more inclusive to ensure we catch everything. Should we?

@mathjazz

Copy link
Copy Markdown
Collaborator

Or is your concern about non-Mozilla Pontoon users? If so, then we're going to need to make the migration quite a bit more inclusive to ensure we catch everything. Should we?

Ah, thanks for clarifying. Leaving the decision to you.

@eemeli
eemeli merged commit 6580a5e into mozilla:main Jul 29, 2026
12 checks passed
@eemeli
eemeli deleted the moz-l10n-update branch July 29, 2026 18:07
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.

Pontoon adds NUMBER() function when saving translation

3 participants