New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 613338 link

Starred by 2 users

Issue metadata

Status: Archived
Owner:
Long OOO (go/where-is-mgiuca)
Closed: Aug 14
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

SubtleNotificationView: revisit use of pipe delimiters for key names

Project Member Reported by mgiuca@chromium.org, May 19 2016

Issue description

The SubtleNotificationView strings have keys with borders around them, like "Press [Esc] to exit". The key names are expressed as pipe-delimited segments in the string like this:
"Press |Esc| to exit".
But in our localizable strings file, the key names are (at the moment) always substitutions, like this:
"Press |$1| to exit".

It's been questioned twice [1, 2] why we do this, instead of either a) hard-coding the key name in the strings file (e.g., "Press |Esc| to exit") or b) just using the substitution and not pipe delimited segments (e.g., "Press $1 to exit").

[1] https://codereview.chromium.org/1421813005/diff/1/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h#newcode93
[2] https://codereview.chromium.org/1995893002/diff/1/chrome/app/generated_resources.grd#newcode12664

The truth is I basically took the middle ground here. (a) is preferable from a translation perspective (as estade@ and some localization people at Google I spoke to offline have recommended). But it's hard to do that because there are so many cases where we want to change the strings (e.g., sometimes you have to press F11 to exit full screen; in the "go back" notification view sometimes it's Alt, sometimes it's ⌘, we may need to swap ← for → depending on RTL). So we would have to permute all the strings with all the different possible keys. These changes can happen dynamically (based on run-time decisions), and also as the code evolves over time (we may want to fix RTL UI bugs without having to redo all the translations). That's why I chose not to do (a) at the time.

(b) is the opposite of (a); we change it so it's impossible to hard-code key names in the string and always use substitutions for key names. It also makes it impossible to use a substitution in these strings for anything that is not a key name. But it means we don't have to parse pipe delimiters, or tell translators to include them. I chose not to do (b) at the time because I didn't want to commit us to always using substitutions for key names when our localization team had told us that is undesirable. It also means SubtleNotificationView has to be strongly coupled with the localization system (as it is now, the client simply passes a pre-substituted string to SubtleNotificationView with pipe characters), so while it makes the code simpler, it makes the design more complex.

So in the end I kept both the substitutions and the pipe characters. It wasn't necessarily the best decision, and it could be changed if someone strongly thinks (a) or (b) are better than the current middle-ground. But TL;DR, localization is hard, and there were good reasons behind my decision to do neither (a) nor (b) at the time.
 
I think we should do what makes sense for the code as it stands at the time.  The majority of the downsides you mention for both (a) and (b) feel to me like "well, if we added more later, this might be annoying".  For (a), I don't think we actually have all that many strings: we don't actually swap the arrows in RTL, so basically we have the fullscreen F11 message and the back and forward messages for Mac and non-Mac.  That's a pretty small number of strings.  Plus, doing this means that the code that displays these doesn't need any kind of parsing at all (even to substitute in things) and indeed can be totally ignorant of what strings it's displaying or how many items are "substituted" in each one; and as you mention, this is optimal for localizing.

Even (b) seems better than what we do now.  The rationale of "not committing us to using substitutions" doesn't seem strong when if we moved away from substitutions, we'd do so to do (a), and in that case we'd want to change the code using these strings to remove any parsing anyway.  As for coupling the notification view with the strings, that seems like Not A Bug to me -- not only do we do this many other places, but conceptually we design the view to act the way it does because we know what we want the UX to be.  I don't think the design is meaningfully more complex in this case, nor do we add conceptual dependencies we didn't already implicitly have.

So I think (a) is a notable win over today, and would do that; and (b) is a smaller win over what we do today.
Status: Archived (was: Assigned)
Archiving old bugs that haven't been modified in over two years. 

If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!

Sign in to add a comment