Page MenuHomePhabricator

Limit validation to certain messages
Open, MediumPublic

Description

Currently limiting the validator to only certain messages is not possible without PHP code. We should consider whether we can add a message key matching support.

In this case the insertables will also be only displayed for those messages.

Example: https://gerrit.wikimedia.org/r/c/translatewiki/+/524669

Details

Related Gerrit Patches:
mediawiki/extensions/Translate : masterAdd support to limit validations to certain messages

Event Timeline

abi_ created this task.Aug 31 2019, 5:11 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 31 2019, 5:11 AM
abi_ updated the task description. (Show Details)Aug 31 2019, 5:16 AM
abi_ added a comment.Oct 21 2019, 11:34 AM

Planning to add support with the following syntax,

# Eg 1: For a specific message key.
VALIDATORS:
    - id: InsertableRegex
      enforce: true
      insertable: true
      params: 
        regex: /\$[a-z0-9]+/
      message: abc

# Eg 2: For a regular expression for keys
VALIDATORS:
    - id: InsertableRegex
      enforce: true
      insertable: true
      params: 
        regex: /\$[a-z0-9]+/
      message: 
        regex: /\[a-z]/

# Eg 3: For a set of message keys
VALIDATORS:
    - id: InsertableRegex
      enforce: true
      insertable: true
      params: 
        regex: /\$[a-z0-9]+/
      messages: 
        - abc
        - xyz
abi_ added a comment.EditedOct 21 2019, 12:03 PM

After discussing with Niklas, following is the structure we've come up with,

---
# This syntax can handle a specific message key / regex / multiple keys.
VALIDATORS:
    - id: InsertableRegex
      enforce: true
      insertable: true
      params: 
        regex: /\$[a-z0-9]+/
      messages: 
        - abc
        - xyz
        - 
          type: regex
          pattern: /\[a-z]/

(Edited after another discussion)

Change 546351 had a related patch set uploaded (by Abijeet Patro; owner: Abijeet Patro):
[mediawiki/extensions/Translate@master] Add support to limit validations to certain messages

https://gerrit.wikimedia.org/r/546351

Change 546351 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Add support to limit validations to certain messages

https://gerrit.wikimedia.org/r/546351

abi_ added a comment.Thu, Nov 28, 3:36 PM

This has been deployed to Translatewiki.net but currently the way to test this would be to merge and deploy this patch - https://gerrit.wikimedia.org/r/c/translatewiki/+/549979

In this patch, we check that the html.direction message for OpenStreetMap can only have value ltr and rtl