Skip to content

Use pgs:switch & pgs:case instead of mf:select for MF2 Xliff representation - #470

Merged
eemeli merged 1 commit into
mainfrom
pgs
Apr 26, 2026
Merged

Use pgs:switch & pgs:case instead of mf:select for MF2 Xliff representation#470
eemeli merged 1 commit into
mainfrom
pgs

Conversation

@eemeli

@eemeli eemeli commented Apr 23, 2026

Copy link
Copy Markdown
Member

Fixes #456

This adopts the attributes introduced in the Plural, Gender, and Select Module that was added in Xliff 2.2 rather than the <unit mf:select> and <segment id> attributes.

The pgs:case values use a *: prefix for the default case, as in *:other or *:nominative. This is a deliberate difference from the Xliff spec's recommendation, to allow for the identifier of the default case to be retained.

CC @srl295, @catamorphism

@srl295

srl295 commented Apr 26, 2026

Copy link
Copy Markdown

Fixes #456

This adopts the attributes introduced in the Plural, Gender, and Select Module that was added in Xliff 2.2 rather than the <unit mf:select> and <segment id> attributes.

Great!

The pgs:case values use a *: prefix for the default case, as in *:other or *:nominative. This is a deliberate difference from the Xliff spec's recommendation, to allow for the identifier of the default case to be retained.

I'm trying to understand this one. Why does the "identifier of the default case" need to be retained, at least for plurals, when "other" is always the default case? Or are there situations where other would not be the default plural?

Maybe answering my own question: Are you trying to preserve the distinction between * and other? I think that's not an important distinction for plurals, in fact, I'd think that * (and not other) should be used in mf2.

What about preserving the non-compliant *:other only if someone passes in other, and using just other if * is used?

@srl295 srl295 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good though a question about *:other

@eemeli

eemeli commented Apr 26, 2026

Copy link
Copy Markdown
Member Author

The pgs:case values use a *: prefix for the default case, as in *:other or *:nominative. This is a deliberate difference from the Xliff spec's recommendation, to allow for the identifier of the default case to be retained.

I'm trying to understand this one. Why does the "identifier of the default case" need to be retained, at least for plurals, when "other" is always the default case? Or are there situations where other would not be the default plural?

@srl295 While the MF2 syntax does not support default case labels, the data model does. It's mostly there to support MF2 being used to represent other syntaxes that do support such labels, like Fluent. The feature itself has a couple of use cases:

  1. Selection on grammatical case, or similar situations where it's useful for a translator to know the actual title for each case, e.g. *:nominative rather than other.
  2. Selection on enums or other sets which do not contain a natural "other". A minimal example of this is selection on a default-true boolean value, where false and *:true are much more useful than false and other.

Maybe answering my own question: Are you trying to preserve the distinction between * and other? I think that's not an important distinction for plurals, in fact, I'd think that * (and not other) should be used in mf2.

For plurals in particular, it's also good to be able to avoid other as a label, in particular for Slavic languages. For example, :integer selection in Polish will only ever resolve to one, few, or many, as other is only used for fractional values. In MF2 syntax we avoid this by the cases for that being one, few, and *.

For Xliff I think we do want to present some textual label here, as we should not presume that either the translator or the tooling working with the file will have any understanding or familiarity with MF2 or its syntax.

What about preserving the non-compliant *:other only if someone passes in other, and using just other if * is used?

Yeah, defaulting to just other does make sense when there isn't a literal "other" case and when no explicit label is provided for the default case. That should probably come as a separate change, though, as it might mean even more finangling of the selection generation. It's been a while since I wrote it, and it gets a bit complicated to account for cases where the source and target use different selectors.

@eemeli
eemeli merged commit 0ffba11 into main Apr 26, 2026
11 checks passed
@eemeli
eemeli deleted the pgs branch April 26, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xliff: use xliff 2.2 schema for plural and gender

2 participants