For the OSM Website project the language direction can either be ltr or rtl.
For this we need a validator that can validate that translation for certain key / keys can be one of a given set.
| abi_ | |
| Sep 5 2019, 11:05 AM |
| F31480801: image.png | |
| Dec 18 2019, 4:40 PM |
For the OSM Website project the language direction can either be ltr or rtl.
For this we need a validator that can validate that translation for certain key / keys can be one of a given set.
| Subject | Repo | Branch | Lines +/- | |
|---|---|---|---|---|
| Add validator to check that translation matches value from a set | mediawiki/extensions/Translate | master | +135 -0 |
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Resolved | None | T195760 Language Annual Plan 2018-2019 | |||
| Resolved | Nikerabbit | T204818 Language tools maintenance intervention: Improve the quality of translations for Translate extension | |||
| Resolved | abi_ | T204568 Extend message checker framework to support errors that prevent saving | |||
| Open | None | T231704 Improving the new validator framework | |||
| Resolved | abi_ | T232084 Add validator to ensure that a certain key / keys can only contain a set of values |
Did we have another task for generic support of limiting the validator only to certain keys? I can't find such one.
Validator name: MatchSetValidator
Syntax
- id: MatchSetValidator
params:
values: # Possible values for the translation
- ltr
- rtl
- hello
min: 1 # Out of the set, atleast one value should be present in translation
max: 2 # Out of the set, atleast two distinct (duplicate: false) values should be present in translation
duplicate: false # Should duplicate values from the set be allowedAdding to the current language board, since this validator will be needed for OSM website.
For now, keeping things simple, and planning to get rid of the min / max parameters. These will be a little trickier to support. For eg, given the above configuration, user translated a string to:
ltr, rtl
We have an extra , above that complicates things. That comma could be instead replaced by a ;, <space>, | etc.
So sticking with the following options for now,
- id: MatchSetValidator
params:
values: # Possible values for the translation
- ltr
- rtl
- hello
caseSensitive: true / false # Whether a case sensitive comparison should be performed. True by default.Change 549977 had a related patch set uploaded (by Abijeet Patro; owner: Abijeet Patro):
[mediawiki/extensions/Translate@master] Add validator to check that translation matches value from a set
Change 549977 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Add validator to check that translation matches value from a set
We've deployed this on translatewiki.net. For OpenStreetMap, the valid values for html.direction have been set to ltr, rtl.