Skip to content

Make active locales optionally repo-dependent#4257

Open
eemeli wants to merge 11 commits into
mozilla:mainfrom
eemeli:repo-locales
Open

Make active locales optionally repo-dependent#4257
eemeli wants to merge 11 commits into
mozilla:mainfrom
eemeli:repo-locales

Conversation

@eemeli

@eemeli eemeli commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #3677

Adds a new control to the top of the /admin/projects/:slug/ page, by default unselected:
Screenshot 2026-06-24 at 19 49 00

If the project uses a config file, the text is slightly different:
Screenshot 2026-06-24 at 19 49 40

And if it's selected and no config file is used, a second checkbox is presented:
Screenshot 2026-06-24 at 19 52 44

Note also how the list of locales is not shown when they're controlled by the repo contents or a config file. The new checkboxes are not shown if the project data source is the database, and not a repository.

Also, when the first checkbox is changed from "off" to "on" or when the config file value changes, the save button is now slightly different:
Screenshot 2026-06-24 at 19 54 09

@mathjazz Is there a way to detect when we're in prod or not? It would probably be good for the sync to use commit=False in dev environments.

The sync behaviour is correspondingly updated so that the ProjectLocale entities are updated if necessary, and the file-existence checks and file-removal changes are only applied if a config file is not used, and both checkboxes are ticked.

@eemeli eemeli requested a review from mathjazz June 24, 2026 17:04
@mathjazz

Copy link
Copy Markdown
Collaborator

Adds a new control to the top of the /admin/projects/:slug/ page, by default unselected:

If the project uses a config file, the text is slightly different:

Should we instead follow the UX of the "Data source" section and use a dropdown (Manual configuration, Read from repository, Read from configuration file)?

Also, checkbox help text looks a little out of place. Is help text even needed for relatively long labels? Or should we just use tooltips or links to the docs? If we stick to the checkboxes, we could take a step closer to the UI unity and use the checkbox style and help text from the settings page.

In any case, this change also requires docs updates.

And if it's selected and no config file is used, a second checkbox is presented:

I had to read the label and the description three times each to understand what this is supposed to do. 😉

Note also how the list of locales is not shown when they're controlled by the repo contents or a config file. The new checkboxes are not shown if the project data source is the database, and not a repository.

Also, when the first checkbox is changed from "off" to "on" or when the config file value changes, the save button is now slightly different:

Why is that? We also require an explicit sync in other cases, e.g. after you first create a project.

Regardless, the button should not break into two lines.

@mathjazz Is there a way to detect when we're in prod or not? It would probably be good for the sync to use commit=False in dev environments.

I don't think so. We should add an environment variable. IS_PRODUCTION_INSTANCE would be useful, ALWAYS_SYNC_WITHOUT_COMMIT might be better.

@eemeli

eemeli commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

Adds a new control to the top of the /admin/projects/:slug/ page, by default unselected:
If the project uses a config file, the text is slightly different:

Should we instead follow the UX of the "Data source" section and use a dropdown (Manual configuration, Read from repository, Read from configuration file)?

Probably not, because the toggle we're actually setting is the same, and it's choosing between manual and repo config. It's just that without a config file, we look for the presence of locale directories, while with a config file we look for their definition in its top-level locales array.

So the choice at this level is binary.

Also, checkbox help text looks a little out of place. Is help text even needed for relatively long labels? Or should we just use tooltips or links to the docs? If we stick to the checkboxes, we could take a step closer to the UI unity and use the checkbox style and help text from the settings page.

Sure; I just followed the full-width style that the page already uses.

I propose that refreshing the project admin page layout and styles ought to be a separate action.

In any case, this change also requires docs updates.

Yes; I held off on that because I figured we'd have this conversation, and the UI might change as a result. 😇

And if it's selected and no config file is used, a second checkbox is presented:

I had to read the label and the description three times each to understand what this is supposed to do. 😉

I welcome suggestions for alternate verbiage.

Note also how the list of locales is not shown when they're controlled by the repo contents or a config file. The new checkboxes are not shown if the project data source is the database, and not a repository.

Also, when the first checkbox is changed from "off" to "on" or when the config file value changes, the save button is now slightly different:

Why is that? We also require an explicit sync in other cases, e.g. after you first create a project.

So you're suggesting we don't force a sync even when we know that the user's choices effectively require one to be effective?

Regardless, the button should not break into two lines.

Fixed now by making it wider, so that it also matches the Pretranslate directly above it.

@mathjazz

Copy link
Copy Markdown
Collaborator

We discussed this issue in more detail and decided to leave any changes to the Project Admin for later (namely #2204).

I suggest we change the checkbox labels and drop the additional help text:

  • Read locale configuration from repository.
  • Read locale configuration from the configuration file.
  • Read translated resource configuration from repository.

BTW, is the 3rd option needed to fix #3677? What's the behaviour, if this checkbox is not selected?

So you're suggesting we don't force a sync even when we know that the user's choices effectively require one to be effective?

That's the current behaviour. E.g. if you add a project or locale.

@flodolo

flodolo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

I suggest we change the checkbox labels and drop the additional help text:

* [ ]  Read locale configuration from repository.

* [ ]  Read locale configuration from the configuration file.

* [ ]  Read translated resource configuration from repository.

I would avoid using "configuration", because it gets confusing fast with configuration file. I'm also not sure I fully understand the 3rd option.

  • Read list of locales from repository
  • Read list of locales from the configuration file
  • Determine localizable resources for each locale from existing resources in repository

I wonder if the 3rd should be a radio button instead, e.g. something along the line of

Localizable resources for each locale:
○ Use only existing resources in repository
◉ Create missing resources based on source locale (default)

@mathjazz

Copy link
Copy Markdown
Collaborator

Also, are we OK without support for read-only locales when locales are read from the repo?

@flodolo

flodolo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Also, are we OK without support for read-only locales when locales are read from the repo?

I think so? We currently use them for one project. If you need read-only, you need to use manual configuration.

@eemeli

eemeli commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

BTW, is the 3rd option needed to fix #3677? What's the behaviour, if this checkbox is not selected?

That's described in #3677 (comment).

Also see the explanation for why it's a good idea at the end of #3677 (comment).

@mathjazz

Copy link
Copy Markdown
Collaborator

That's described in #3677 (comment).

Also see the explanation for why it's a good idea at the end of #3677 (comment).

Thanks.

Why is the resource toggle only available if the first toggle is set to Yes, i.e. if locales are read from repository?

@eemeli

eemeli commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Why is the resource toggle only available if the first toggle is set to Yes, i.e. if locales are read from repository?

If locales were controlled from Pontoon but translated resources from the repo, then in order to add a locale you'd need to:

  1. Add the locale in Pontoon.
  2. Add the locale dir manually.
  3. Add the translated resource files manually.

And I can't think of a situation where you would actually want to do that.

@mathjazz

Copy link
Copy Markdown
Collaborator

If locales were controlled from Pontoon but translated resources from the repo, then in order to add a locale you'd need to:

1. Add the locale in Pontoon.
2. Add the locale dir manually.
3. Add the translated resource files manually.

And I can't think of a situation where you would actually want to do that.

This is what we've been doing for some projects, though:
https://pontoon.mozilla.org/projects/foundation-website-content/

Are you suggesting that we instead require reading locales for such projects from the repository?

@eemeli

eemeli commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

This is what we've been doing for some projects, though: https://pontoon.mozilla.org/projects/foundation-website-content/

Are you suggesting that we instead require reading locales for such projects from the repository?

Yes; for that project I think it'd be appropriate to have the locales and translated resources set only by the repository contents, rather than needing to also set them in Pontoon.

@mathjazz

Copy link
Copy Markdown
Collaborator

That sounds good.

Then for the 3rd checkbox, I agree with @flodolo we should use a radio button to make it more explicit. Another attempt at improving the wording:

  • All source resources are available for all locales. [default]
  • Only resources that exist in locale directories are available for localization.

@eemeli

eemeli commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Applied the changes discussed above; PTAL?

@mathjazz

mathjazz commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Applied the changes discussed above; PTAL?

Looks good. Is the "Read list of locales from the configuration file" option now implicit?

@eemeli

eemeli commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Looks good. Is the "Read list of locales from the configuration file" option now implicit?

I don't understand the question. The checkbox label for set_locales_from_repo is now "Read list of locales from the configuration file" when the configuration_file value is non-empty.

@mathjazz

mathjazz commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Ah, thanks for clarifying.

@flodolo

flodolo commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

We need to get into the habit of updating docs in the same PR as the code changes.

https://pontoon.mozilla.org/docs/admin/adding-new-project/

@mathjazz

mathjazz commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Good point. The underlying issue is a bug, which (rightfully) didn't have the needs documentation label assigned. It's just that the fix for it turned out to be a feature. Adding a label here.

@eemeli eemeli requested a review from flodolo July 6, 2026 09:32
Comment thread documentation/docs/admin/adding-new-project.md Outdated
Comment thread documentation/docs/admin/adding-new-project.md Outdated
Comment thread documentation/docs/admin/adding-new-project.md Outdated
Co-authored-by: Francesco Lodolo <flodolo@mozilla.com>
@eemeli eemeli requested a review from flodolo July 6, 2026 12:44
Comment thread documentation/docs/admin/adding-new-project.md
Co-authored-by: Francesco Lodolo <flod@lodolo.net>
@flodolo

flodolo commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Note on deployment:

  • Before deploying this to production, we need to disable sync for https://pontoon.mozilla.org/projects/foundation-website-content/
  • Once deployed, we need to set this repository to only use resources available in the repository
  • We need to manually run sync (potentially a forced one) to confirm that Pontoon is not adding new resources in the UI or in the repository.
  • If everything looks good, re-enable sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding new locales to Gettext projects directly from Pontoon is no longer possible

3 participants