Skip to content

Write resources without fetch, using data model fields - #4391

Merged
mathjazz merged 7 commits into
mozilla:mainfrom
eemeli:write-from-db
Aug 24, 2026
Merged

mathjazz merged 7 commits into
mozilla:mainfrom
eemeli:write-from-db

Conversation

@eemeli

@eemeli eemeli commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

After merging this, mozilla/webservices-infra#9295 should be reverted.

The serialization is changed to rely on data we store during the sync, and on the data model representations of translations, rather than on re-parsing the source resource and patching it with strings.

This will mean that the serialization will change for rather many files, as e.g. standalone comments are getting dropped.

The three commits here could also be filed each as separate stacked PRs; please let me know if that would be preferable.

Direct downloads of translated resources are re-enabled. Their UX is essentially unchanged from the current one, i.e. only single file downloads are offered. We could and should iterate on this to address other pre-existing issues, but as later work.

@codecov-commenter

codecov-commenter commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.42268% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.67%. Comparing base (157b622) to head (ac12f8d).
⚠️ Report is 9 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.

@eemeli
eemeli marked this pull request as ready for review August 13, 2026 16:03
@eemeli
eemeli requested a review from mathjazz August 13, 2026 16:36

@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.

A few high-level notes and a coupe inline.

.exclude(approved_date__gt=now) # includes approved_date = None
.select_related("entity")
)
res = build_moz_l10n_resource(db_res)

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.

Previously, res = parse_resource(ref_path) was inside a try - catch, so the sync carried on in case of an error. Now it seems like it fails for the whole project.

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.

I think that's appropriate? The only reasons this should throw are indicators of something being seriously wrong, and we probably should not continue with a sync in that case.

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.

OK if that's a conscious change.

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.

Yes, this is intentional.

Comment thread pontoon/base/views.py Resolved
Comment thread pontoon/sync/utils.py Resolved
@flodolo

flodolo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Tested with my locale instance, this is Firefox
mozilla-l10n/firefox-l10n@5a077eb

  • I'm a bit surprised by the reordering of parameters in the DATETIME() functions or parameterized terms. What's the logic?
  • I understand some of the closing group-level comments being removed, since they were never open. But there are entire group-level comments removed (e.g. it/browser/browser/aiFeatures.ftl, it/browser/browser/fxviewTabList.ftl) that looks incorrect.

@flodolo

flodolo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Can't reproduce with my local instance. Could it be a problem with MF2-related data migrations?

@eemeli

eemeli commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

I got ValueError: A @fluent-fn attribute is required for :platform when trying to download http://localhost:8000/sl/firefox/browser/browser/aboutLogins.ftl?string=200689

This does not replicate for me.

Does the patch also fix #4107?

No, downloading source/template files is a separate issue.

Why do we download single files as ZIP?

No good reason; that's what the now-removed download_translations_zip() was doing. Now sending them as text/plain.

We should also allow for download (of all project resources) from the All Resources view (or is that #2134)?

Yeah, let's address that in a separate PR.

@eemeli

eemeli commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

I'm a bit surprised by the reordering of parameters in the DATETIME() functions or parameterized terms. What's the logic?

mozilla/moz-l10n#193

I understand some of the closing group-level comments being removed, since they were never open. But there are entire group-level comments removed (e.g. it/browser/browser/aiFeatures.ftl, it/browser/browser/fxviewTabList.ftl) that looks incorrect.

I'm not seeing that. Have you run a force-sync for firefox on your server after #4374 was merged?

@flodolo

flodolo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

mozilla/moz-l10n#193

It doesn't match? It serialized day/year/month, I'd expect day/month/year.

I'm not seeing that. Have you run a force-sync for firefox on your server after #4374 was merged?

I'm positive I did several times, but unfortunately I can't tell from Docker's logs 🤔

I do it frequently to remove empty trailing lines that I add to trigger the production instance sync
mozilla-l10n/firefox-l10n@eb2771d

@eemeli

eemeli commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

mozilla/moz-l10n#193

It doesn't match? It serialized day/year/month, I'd expect day/month/year.

Locally, I'm seeing day/month/year when serialising /it/firefox/browser/browser/aboutLogins.ftl. Are you using moz-l10n 0.14.0 or 0.14.1?

@flodolo

flodolo commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Locally, I'm seeing day/month/year when serialising /it/firefox/browser/browser/aboutLogins.ftl. Are you using moz-l10n 0.14.0 or 0.14.1?

That's dumb, I missed the dependency update in this PR 🤦🏼

Saw this comment only after I started rebuilding the image, and the image is now using 0.14.1.

The variable order is fixed mozilla-l10n/firefox-l10n@8a5fb3a

But it doesn't look like it restored those group-level comments.

EDIT: I reverted the last 2 commits, and added a new forced sync, so the diff against the output of this branch is clearer
mozilla-l10n/firefox-l10n@7e7c2ea

@eemeli

eemeli commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

it doesn't look like it restored those group-level comments.

Does the group-level comment show up on your instance for e.g. this string?

https://pontoon.mozilla.org/it/firefox/browser/browser/aiFeatures.ftl/?string=337021

@flodolo

flodolo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Does the group-level comment show up on your instance for e.g. this string?

Yes.

Screenshot 2026-08-18 alle 13 33 09

@flodolo

flodolo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

For both aiFeatures.flt  and  browser.ftl  the comment is currently duplicated.

Example:
https://github.com/mozilla-l10n/firefox-l10n/blob/ff33c118d557c7aa89be33e92a40cabae61c826f/it/browser/browser/aiFeatures.ftl#L37-L40

https://github.com/mozilla-l10n/firefox-l10n/blob/ff33c118d557c7aa89be33e92a40cabae61c826f/it/browser/browser/aiFeatures.ftl#L99-L102

This is likely a side-effect of the merge from cross-channel. So, this patch is doing the right thing, what's confusing is why these changes don't show up on your side if you test it.

@eemeli

eemeli commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

So, this patch is doing the right thing, what's confusing is why these changes don't show up on your side if you test it.

I think I was seeing a group comment matching the one that was being removed as being included in my local results, and not noticing that the source had two comments with the same contents.

@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.

Looks good, thanks for the update!

It seems like this also fixes #3517?

Relatedly, it seems like fixing #3596 will require more data model changes?

.exclude(approved_date__gt=now) # includes approved_date = None
.select_related("entity")
)
res = build_moz_l10n_resource(db_res)

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.

OK if that's a conscious change.

@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.

Seems like Flod found some issues that have not been resolved yet.

@flodolo

flodolo commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Seems like Flod found some issues that have not been resolved yet.

Everything good on my side, the code is actually cleaning up cruft that are created over time by the cross-channel merge (duplicate group-level comments, closing group-level comments that were never open). There's no user impact in Pontoon.

@flodolo

flodolo commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

I've also been running this locally for a week without any issue, so it's safe to merge.
I'm sure we'll find some issue in an obscure project at some point 😅

@flodolo

flodolo commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

It seems like this also fixes #3517?

A forced push for Italian on VPN didn't produce any diff.

The issue is also "fixed" on the automation side, as we now only extract the source file, and leave localized files alone (Pontoon manages these).

@eemeli

eemeli commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

It seems like this also fixes #3517?

Looks like it, as the metadata is now always the same as in source.

Relatedly, it seems like fixing #3596 will require more data model changes?

Correct; no data model changes are included here.

@mathjazz
mathjazz merged commit 707712d into mozilla:main Aug 24, 2026
10 checks passed
@eemeli
eemeli deleted the write-from-db branch August 27, 2026 08:17
mathjazz added a commit that referenced this pull request Aug 31, 2026
Migration 0111 restored the catchall label as `other` for every locale.

Gettext addresses plural forms by category, so in a locale whose
categories are `one, few, many` a catchall labelled `other` matches no form
and is serialized as an empty msgstr, dropping the translation from the repository.

This affects be, pl, ru, szl and uk, and surfaced only once #4391 began
writing resources from the data model rather than the previous path.
mathjazz added a commit that referenced this pull request Aug 31, 2026
Migration 0111 restored the catchall label as `other` for every locale.

Gettext addresses plural forms by category, so in a locale whose
categories are `one, few, many` a catchall labelled `other` matches no form
and is serialized as an empty msgstr, dropping the translation from the repository.

This affects be, pl, ru, szl and uk, and surfaced only once #4391 began
writing resources from the data model rather than the previous path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants