Translations on supported branches

Hi everyone,

while browsing the documentation of Weblate this morning I had a new idea for providing support of translations to multiple branches for XS.

To sum up quickly the context: in XWiki Standard we want to have translations provided to the main branches of our repository, but we also want to have them propagated to the supported branches (e.g. LTS). Right now, the process is to backport the changes with some scripts during the release, but it’s currently tedious and error prone, and at the moment we regularly avoid doing those backports to avoid breaking something.

The idea I have is fairly simple: it consists in duplicating every components in Weblate for all supported branches, and to configure those components to pull and push on their branches, and to use a smart little configuration name “Allow translation propagation” which ensures that all translations related to the same key are propagated in different components.

There’s several benefits of this solution:

  1. we would really only translate what is in the source translation file in the given branches, we won’t have risk anymore to wrongly backport translations changes
  2. obviously the release process would be simplified a lot
  3. we manage everything from Weblate itself: no other tooling, no need to extra script anywhere (edit: not really true actually, see below)

And I can see at least 3 major problems:

  1. it will create a lot of components in Weblate, and AFAIU from the “Allow translation propagation” they’ll need to be put in same Weblate Project for that config to work. So for example in XWiki Platform project in Weblate, right now we have 124 components: we’d need to multiply this by the number of branches we support, so it would be around 124 * 3 branches = 372 components in Weblate for that project (the biggest one)
  2. we will need to handle the creation and deletion of those components in Weblate when a new supported branch is created/deleted (or maybe to update their branch info)
  3. we will get more Weblate PR to handle: any propagated translation will create other PR(s) for the branches it impacts

For point 1, there’s 2 aspects, a performance aspect on Weblate, and an organizational aspect to not loose everyone with duplicated components. For the performance aspect, I don’t think it’s a real issue: we never had performance problems in the past, I might investigate a bit more on the subject but I believe it should fit on the current machine. For the organization aspect, one of the first idea I have is to use Weblate “Categories”: those can be seen as “folders” in the UI where we can put other categories and/or components. I started to use them to organize a bit the components already in XWiki Platform (e.g. the xwiki-platform-extension category), we could add another layer such as one category per branch, and then reorganize below those categories. We could also check to use labels, but I think it might not be enough as we would still see all components when accessing the UI. An important thing also will be to have proper naming for the component on branches to identify them quickly in UIs that might present several components at once (and for administration tasks). Now another idea to be discussed for helping translators, could be to decide to make those branch components private: we would decide that those are only technical, propagation is allowed but they shouldn’t be directly translated and so they shouldn’t be visible. I’d need to check how it works exactly, but it would avoid seeing too many things in the UI for our translators.

For point 2, we will obviously need custom tooling. Now the REST API of Weblate is properly documented and I think it shouldn’t be too complicated to use that (e.g. see creating a component with REST API). Note that we might also only need to create a single component: we’re already using a Weblate addon to automatically discover components based on regular expressions: we could probably use same mechanism. Basically we’d create oldcore component, and all other ones of the repo would be created automatically by the discovery addon. So could be actually quite easier than I even thought before writing this :slight_smile:

I don’t think point 3 is a real issue: it’s just another PR to handle and it should probably be very fast to handle them.
Note that my idea so far for solving the main problem was already to automatically create backport PRs for other branches, so it wouldn’t change anything here.

WDYT? Unless someone strongly disagrees, I’d like to give a try just by creating manually a single branch components on xwiki-platform, e.g. for 15.10.x knowing that we had quite a changes and we haven’t propagated translation there: it would be an interesting test to see how it goes.

+1 to try it, to verify it works.

Globally, it seems ok-ish, not the best for sure but possibly acceptable. I’m indeed worried about problem # 3. I’d also be in favor of hiding the branches from the translators to make it simpler.

Thanks!

+1 to make the branch components private to hide them to most people to start

I guess we “just” need some script (either scheduled or right in the pipeline, triggered in parallel at the beginning of each build) which check for each component of the project if it has a version matching the current branch.

Well also need something to cleanup when a branch is not supported anymore.

This is not a problem IMO, as I don’t think we want anything coming from Weblate to be automatically committed anyway.

No it won’t work all the time: you could have a component added on master and not existing on LTS. Or on the contrary a component removed on master and existing in LTS. That’s actually the case between master and 15.10.x currently with the move of messagestream to legacy, and that’s why I want to try with that branch to see if the discovery addon would be enough for that UC.

Sure, but it’s easy to check if the file associated to this component exist on that branch.

+1 for the general idea, and thanks for working on this, really quality of life improvements for release managers if you ask me.

So I did give it a try, I performed the following operations:

  1. I created a category “stable-15.10.x” in Weblate for XWiki Platform
  2. I created manually a new component xwiki-oldcore-1510x to perform translations of oldcore on stable-15.10.x branch only, and I made it restricted (so it doesn’t appear to translators, and apparently it doesn’t appear even to myself in the category)
  3. I configured the Discovery addon for 15.10.x branch to automatically create all components for Java properties translations formats, reusing the configuration we already had
  4. I checked that the property for propagating translation was set to true
  5. I then performed a few translations in the components linked to master

I obtained 2 pull requests: 1 for master and 1 for 15.10.x

So, for me it proves that the idea work in general. Now I noticed one thing: apparently there’s no way (but I haven’t yet investigated much on it) to specify that the components created through discovery addon will be restricted. That’s why you can see all components under the stable-15.10.x category. Now I’m not so sure it’s really an issue, knowing that I use an explicit naming scheme to specify that it’s 15.10.x components, and that they’re not visible until you go to the category… The fact I cannot myself see the restricted component (but I can access it) is more of an issue IMO.

There’s another small problem on the long run: I can use the Discovery addons for Java properties format because the filename is standard and I can use a regex. I’m currently using also a regex for XWiki translation pages, are they’re supposed to contains “Translations” in their name and to have .xml extension. But if the Discovery addon cannot find translations not matching those names. This is a bit mitigated with the idea also proposed by @tmortagne to actually duplicate existing components for master in other branches, and checking that the file exists.

So I’d like to proceed on writing the script for creating automatically the category and components for a branch. And on the script for deleting automatically the components for a branch too. With testing those on 16.10.x and 15.10.x. WDYT?

For information, I haven’t yet created the scripts, but I manually created the different categories for our supported branches (15.10.x, 16.10.x and 16.4.x) that contains all components for java properties and XWiki page properties translations, using the discovery addons. I’ve done it only in xwiki-platform since we have very few translations components in commons and rendering: we can easily backport the translations PRs using labels for those for now IMO.

I also edited the release plan template to remove the instruction for merging translations during releases in the future. I do kept the information in release help though, if we need it again later, I only added a warning.

For the scripts I created a ticket for doing it in a near future: Loading...

There is one thing I don’t like: all approvals had to be done again. If it’s a string in english the same as in german or the same word two times following (“die die” is happening a lot in german). I now have to approve 267 translations I already did along the last years.

I’m already on it so nothing to do at the moment but maybe there is an option to pass those approvals while duplicating “old” translations?

Hmmm thanks for the feedback, I’m not sure I have a solution for this on the long run though. I’ll need to think about that.

It’s probably an edge case, but if a key is translated only once, and the translation is propagated to all the components that include that key (IIUC), it means we need to be careful when the default value (English) changes between XWiki versions. I know we are supposed to introduce a new key when the meaning changes significantly, but sometimes there’s only a small update in the English value that may be inaccurate or misleading for the previous XWiki branches.

+1 otherwise, thanks for working on this.

A bit of feedback on this: I actually rolled back my changes, by removing the components I created for the supported branches, because of a bug in Weblate creating multiple components with same name, leading to multiple errors.
I’ll perform the changes again, but after upgrading Weblate in january.