Problem/Motivation

Now that Drupal 8 downloads real Drupal 8 translations following #1914070: Improve version fallback for install language., we can go and figure out translation problems. I found a big one right away with the "Extend" menu item. Looks like "Extend" is a word used elsewhere as "make it apply for a longer time" at least I assume that may be the case with the "Auto expire" module for example. Drupal 8 menu uses this as "add more components". This is an English word that is ambiguous for translation and would need context to disambiguate. Now the problem is menus / routing / tabs don't allow for such context to be specified.

The very concrete problem at hand is the Hungarian team translated "Extend" as the Hungarian equivalent of "lengthen" (ie. "extend my vacation", instead of "extend" as in "extend the system with more components"). I went to *fix* the translation, but given how wide this applies to, "fixing" it may as well brake it for other uses:

Mistranslation as appears in Drupal 8: ExtendHun.png

Mistranslation as it appears on localize.drupal.org: ExtendLDO.png

Proposed resolution

1. Need way to attach context to strings in routing / tabs / contextual links and apply context to at least the string "Extend". As more ambiguous strings are found, apply context to those too. Covered by #2114069: Routing / tabs / actions lack way to attach context to UI strings.
2. Carry that over to the menu system. Covered by this patch.

Remaining tasks

- Figure out how to take over the context from routes/tabs/actions to the menu system.

User interface changes

None.

API changes

A way to carry on context for strings from routing / tabs / contextual links.

#2114069: Routing / tabs / actions lack way to attach context to UI strings provides the data to use.

Comments

gábor hojtsy’s picture

yesct’s picture

andypost’s picture

I think the issue should be a part of meta to figure out a primary context names, the same as we use for query and cache tags

Contexts are used in filter form for translation so better to keep the list a short as possible

So for menu items we could apply 'Menu title' context - otoh #2114069: Routing / tabs / actions lack way to attach context to UI strings did a 'With components' for single menu item

gábor hojtsy’s picture

@andypost: I don't think you want to translate "Edit" separate for when it is a menu item or button label or tab or contextual link. I don't think the use of place of the text is relevant for translation context. 'Extend' as a menu item or 'Views' as a menu item can still mean many different things. Eg if you have a service with a subscriptions menu with an 'Extend' item, that would mean "Extend time of my subscription" or "Extend with modules" as in the Drupal menu. Wholesale contexting like "Menu item" does not really help provide context.

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -sprint

This is postponed on menu changes I think, namely #2256497: [meta] Menu Links - New Plan for the Homestretch.

gábor hojtsy’s picture

Added support for title_context extraction to the extractor patch at #2254561: Support string extraction for Drupal 8 menu_links.yml with anticipation this would use the same API as local tasks, contextual links and actions. I think that is a fair assumption.

gábor hojtsy’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Looks like this has been independently resolved in the menu refactoring. MenuLinkManager::$defaults has this:

    // The static title for the menu link. You can specify placeholders like on
    // any translatable string and the values in title_arguments.
    'title' => '',
    // The values for the menu link placeholders.
    'title_arguments' => array(),
    // A context for the title string.
    // @see \Drupal\Core\StringTranslation\TranslationInterface::translate()
    'title_context' => '',
gábor hojtsy’s picture

Also updated docs at https://www.drupal.org/node/2122241, added this para:

Finally, you can provide string context for the menu link title in a title_context key, so if the link text is ambiguous (such as 'Extend', 'May', etc.) the string context helps translators pick the right translation. This is later passed on to t().