Page MenuHomePhabricator

Consider combining templates.json and tests.json into a single paths.json configuration file
Closed, ResolvedPublic

Description

We now have three separate configuration files possible per domain: templates.json, tests.json and patterns.json. This separation was meant to minimize edit conflicts and to enable finer-grained protection in case of vandalism. It also allows to more easily identify contributors focusing on either templates or tests.

With Web2Cit-Editor, all configuration parts would have been seamlessly integrated into one single configuration interface. However, this hasn't been implemented. Instead, the Web2Cit-JSON-Editor reinforces this separation, offering a separate form for each configuration file.

As a result, it is often the case that a translation template is defined without a corresponding translation test, or without even indicating a specific path at all. This hinders collaborative maintenance of these configuration files. See for example here.

One possible solution to encourage a specific path be set for a template is to remove the "/" suggestion from the form (T337131). However, this wouldn't prevent editors from skipping translation tests for that path.

Additionally, the Web2Cit-Server's summary page may be adapted by (1) switching the order of the columns (translation goal first, translation output second), and (2) warning the user if they click on edit output when an expectation is not available.

However, the best possible solution may be to join the templates.json and tests.json files into a single paths.json file. This way, the user would be forced to first set a path, then add a field, set an expected output and only then define a translation procedure (if wanted).

If this change is applied, we will have to run a script that automatically converts templates.json and tests.json files into paths.json. Maybe consider merging one into the other to preserve edit history as much as possible.

Documentation should be updated accordingly as well.

Event Timeline

Also note what would happen if a path and field, for which a procedure has been defined but no goal has been set, is opened by the Web2Cit-JSON-Editor form? Will it fail? Will it prevent users from saving until the error has been fixed?

If this change is applied, we will have to run a script that automatically converts templates.json and tests.json files into paths.json. Maybe consider merging one into the other to preserve edit history as much as possible.

Alternatively, we may also want to create a separate paths.json first and have the Web2Cit-JSON-Editor and Web2Cit-Server use that, but keep templates.json and tests.json for a while just in case.

diegodlh changed the task status from Open to In Progress.May 19 2026, 1:26 AM

Solved by using dynamically-generated templates JSON schema including a list of allowed paths as determined by the tests paths defined in the corresponding translation tests configuration file.

This list of allowed paths is dynamically injected into the templates schema when schema is requested with custom domain and optional sandbox query string parameters.

This kind of dynamic generation of JSON schemas may pave the way for supporting T308347 and T316951.

Link to JSON editor for editing translation templates has been updated accordingly.

In addition, JSON editor was updated to provide a custom validation error in cases where a path not matching one of the test paths has already been defined.

Implemented in Web2Cit-Server and Web2Cit-JSON-Editor with 4e046331.

Updated description and info in templates schema accordingly in Web2Cit-Core with ec019f73.

Updated Server documentation with https://meta.wikimedia.org/w/index.php?title=Web2Cit/Docs/Server&diff=prev&oldid=30562878.

Pending Web2Cit core library update in w2c-server and deployment.

In addition, JSON editor was updated to provide a custom validation error in cases where a path not matching one of the test paths has already been defined.

Note this is only being show if no test paths have been defined. Otherwise, one of the test paths is chosen instead, and the error is not shown. Maybe this could be fixed if there was a way to not automatically choose one of the enum values?

Maybe this could be fixed if there was a way to not automatically choose one of the enum values?

Fixed by using has_placeholder_option in 1411d40c. Had to update json-editor to newer version.

diegodlh claimed this task.

Deployed with w2c-server v1.4.0