-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add use case for source
expression attribute
#772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
An argument can be made that this is a job for markup, since, after all, an XLIFF processor might want to directly consume the
Side thought: we probably want to chat with the Apple, Android, and MSFT folks about adopting MF2 into some of their resource/API syntaxes.
I'm not sure I understand the Apple's doc furnishes this example of the format you're talking about: <plist version="1.0">
<dict>
<key>%d home(s) found</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@homes@</string>
<key>homes</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No homes found</string>
<key>one</key>
<string>%d home found</string>
<key>other</key>
<string>%d homes found</string>
</dict>
</dict>
</dict>
</plist> Isn't this represented in MF2 as:
The |
I'm building a workflow where the source content can be parsed into an MF2 data model, modified, and then reserialised in the original format. So there isn't necessarily any XLIFF processor involved here, and even if there were, the use of
In this case, there is no formatter involved in the workflow, so the source needs to be retained to allow for a later serialisation in the format that the iOS or MacOS formatter will be able to process. For the translator, the name of the variable can be an informative part of the message's context, and it's much clearer when lifted out of its syntax trappings.
Yes, and in the MF2 representation the |
Agreed, but one could extract the name (and/or decorate) the name to generate the expression operand. I understand that the
👍
Understood, but there is Android's processor and this does still look like markup in that context. FWIW, XLIFF elements are implemented in many different ways by different tools. So there are many dialects already. Overall, what you're doing can obviously work. I'm just curious whether we already provide the necessary constructs. Thought: does this suggest the need for namespaced or custom attributes? |
Eh, or I can just extract the relevant-to-translators bit out of it (the variable name), and leave the rest as line noise that I hide away. The "IIUC" bit that you mention is hard here, because this syntax isn't well documented, and I'm not myself 100% confident I've understood all of it.
Yes, and in some cases like <xliff:g><b>foo</b></xliff:g> I do need to leave it in as markup like
but that's less useful and less friendly to a translator or tooling than e.g. representing <xliff:g id="user" example="Bob">%1$s</xliff:g> as
That's actually a big part of why I opened this PR. If we find agreement on what a |
Note that the way It is meant to declare the text between I though that "do not translate" is already representable in MF2 as |
While working on moz.l10n, a new Python localization library that uses the MF2 message and resource data model to represent messages from a number of different current syntaxes, I've come across at least the following use cases for expression attributes:
<xliff:g>
to wrap nontranslatable content. This is best represented in MF2 with a@translate=no
attribute.messages.json
files allow for named placeholders that are mapped to indexed arguments. These may include an example, which is best represented in MF2 as an@example=...
attribute..stringsdict
XML files, which encode the plural variable's name as aNSStringLocalizedFormatKey
value, where it appears as e.g.%#@countOfFoo@
or similar. To display only the relevant "countOfFoo" name of this variable to localizers as context, it's best to use a@source=...
attribute on the selector.The first two use cases are already documented, but the last one is not; it's added by this PR.
The overall use case of the underlying work is to make use of the MF2 data model to provide a unified representation of messages in many different syntaxes, so that e.g. validation and a UI for plural message editing can be applied to all formats, rather than needing separate parsing and handling for each.