This was already discussed many times (especially in #19425): several strings (both in Drupal Core and in contrib) are simply too short not to be ambiguous in some languages. For example 'View', as in 'a view of the Views module', and 'View' as in the action of viewing something (a node, a user, etc.).
It boils down to this:
- There are really very few cases where this happens. Thus we don't need a full featured context system, that will make lookups expensive.
- Thus, we can simply add the context to those strings manually.
- We need that information to be embedded inside .po files.
I suggest we come up with a convention like that one:
- Strings passed to t() can be prefixed with an optional context. The exact way of doing that has to be discussed, but I suggest the
[<context>]<string>convention, as it should not collide with existing strings, both in core and contrib.
- For English, the context is simply automatically stripped by t().
- For other languages, the full string, including the context is used as the lookup key. No fallback mechanism is implemented.
- The full string is exported to .po files by potx, which thus requires no modification.
// Short names in format_date() and such. t("[short-week]Mon"); t("[short-week]Tue"); t("[short-week]Wed"); // View tab $items['user/%user/view'] = array( 'title' => '[user-tab]View', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); // etc.
Passed: 13707 passes, 0 fails, 0 exceptions View
|#111||msgctxt-bugs.patch||1.8 KB||Gábor Hojtsy|
|#82||334283-translation-context.patch||56.5 KB||Damien Tournoud|