unicode-org / message-format-wg

Developing a standard for localizable message strings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Point of view (grammatical person)

jamiebuilds opened this issue · comments

Problem

(Apologies for using 1.0 syntax, it's what I know)

Messages are often (mistakenly) hard-coded to combine first/second-person and third-person by developers. For example:

{name} reacted with {emoji}
You reacted with emoji
Jamie reacted with emoji

In English, this feels right besides passing in You from a totally separate translation. But it's not correct for languages that need to know if its in first or third person.

Instead you should be doing one of the following:

second = You reacted with {emoji}
third = {name} reacted with {emoji}
// or
combined = {who, select, me {You} other {{name}}} reacted with {emoji}

Splitting the strings is a bit unfortunate when this could be a lot of repeated complexity in the string.

Solution

I don't have a great suggestion here, but I saw that the 2.0 syntax included a :person so maybe that could be leveraged to do a better job here?

Prior Art

Facebook's fbt framework includes implicit parameters for __subject__ and __viewing__user__

https://facebook.github.io/fbt/docs/implicit_params

@jamiebuilds Thanks for reaching out. You might want to post this in Discussions, since we use issues to manage specification development.


MF2 might be used to solve this kind of problem, although some of the details may not be available in all implementations or at release. The challenge here is verb/noun agreement, which can include various details, such as gender, count, level of formality. The :person function is not yet defined in the default registry, but will likely be based on PersonNameFormatter in ICU. ICU's API has some ability to expose selectable parts of a personal name in ways that could be used to solve the problem at hand.

Another aspect of MF2 is that it does not allow substring selection, as in your example:

combined = {who, select, me {You} other {{name}}} reacted with {emoji}

This is an internationalization bug, since the verb "reacted" needs to interact with the noun. In MF2's syntax, the .match statement always goes outside the list of patterns. So your example would look like:

.match {$who :select}
me  {{You reacted with {$emoji}}}
*   {{{$name} reacted with {$emoji}}}

This doesn't show the need for other types of matching, such as gender, but should give you an idea how MF2 can be used to solve the problem.

Finally, note that an FBT implementation might expose "subject" and "viewing user" as attributes or as build-in selectors.

Closing as addressed. Feel free to write to the group, reopen, or file a new issue if needed.