Open SimonClark opened 9 months ago
These sorts of modifiers are perhaps best handled in the message format itself; they're a core feature of MF2. With that, your examples could be expressed as:
mouse_ItemName = .match {$num :plural}
one {{mouse}}
* {{mice}}
iPhone_ItemName = .match {$pos :position}
sentence-start {{iPhone}}
* {{iPhone}}
raccoon_ItemName = .match {$tone :tone} {$count :plural}
slang one {{trash panda}}
slang * {{trash pandas}}
* one {{raccoon}}
* * {{raccoons}}
taxJurisdiction_FieldLabel = .match {$locale :region}
us {{Nexus}
* {{Tax jurisdiction}}
Note that all of the non-pattern whitespace in MF2 effectively collapses to a single space, so it's there only for legibility.
Also, only the :plural
selector of the above is included in the MF2 core set; all the others would need some custom implementations.
Yes, good point. And in many cases this might be the ideal solution.
One of the usecases that I am trying to solve for is where the variants and the parameters may be more freeform and unknown at authoring time.
Suppose I have field level help for a "Subsidiary" field on my employee record. The field level help states that the subsidiary field is not mandatory.
A partner delivers a new platform app that pays benefits in the Canadian market. So, if that app is installed and if the employee is Canadian, then the partner needs to deliver a variant of field level help that will only be seen on employee forms of Canadian employees.
They should be able to deliver a resource file that is merged in with the existing resources
@modifiers canadian_employee
employeeSubsidiary_FieldHelp = The subsidiary must be specified for Canadian employees in order to pay CPP benefits
As a resource bundle author, I want to specify variations of a string...
Further, it should be possible to specify multiple modifiers:
I would expect there to be a set of common modifiers that most implementors would find useful, however, the modifiers should not be limited to that set, but open for extension...