Problem/Motivation

In #2031885: Add t() context to "Order" string. there was added language context for "Order" word used in sorting context, meantime views got no change

Proposed resolution

Add context to views usage

Remaining tasks

decide on test and commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

Original report by @Kartagis

We have languages in which a word could have different meanings. One of those languages is Turkish, which is my native language. One particular example I could give is this word, which could mean either sıra, sipariş depending on whether it's coming from Core or Commerce. Order is listed under both Core and Commerce. So, there needs to be a more grained context differentiation system.

CommentFileSizeAuthor
#3 3064523-3.patch720 bytesandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kartagis created an issue. See original summary.

andypost’s picture

It's hard to guess which words require contexts, so better to manage it on per word basis

EDIT Like #2965786: Translation of "Checked" as used on the Status page needs context

andypost’s picture

Status: Active » Needs review
FileSize
720 bytes

So there's just views to fix

$ git grep -F "'Order'"
core/includes/theme.inc:1633:      t('Order', [], ['context' => 'Sort order']),
core/modules/migrate_drupal/tests/fixtures/drupal6.php:11011:  'source' => 'Order',
core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php:244:          '#title' => $this->t('Order', [], ['context' => 'Sort order']),
core/modules/views/src/Plugin/views/sort/SortPluginBase.php:172:        '#title' => $this->t('Order'),
andypost’s picture

andypost’s picture

Title: Allow to specify context for translations » Add t() context to "Order" string for views module
Category: Feature request » Bug report
Issue summary: View changes
Issue tags: -Needs issue summary update +language-ui
Kartagis’s picture

By the way, it's not only Order. We need a more grained context specification for any word.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

The result of git grep -F "'Order'" is still the same in 8.9.x as in #3.

As far as I has searched, only one translation of Order needs to be fixed. That is what his patch does.

Kartagis’s picture

Another pair just came to my mind. State may mean Eyalet or Durum depending on whether it's Commerce or Core, respectively.

Sutharsan’s picture

@Kartagis, If you think this should be fixed, than create a new issue for it.

Personally I don't think core should fix every translation context that occurs with contrib modules. This issue makes existing contexts applied consistently. Consider creating an issue with Commerce module for this context.

alexpott’s picture

Version: 8.9.x-dev » 8.8.x-dev
Component: locale.module » views.module
Status: Reviewed & tested by the community » Fixed

So we already have single word translations of Order with this context so I think we can fix this in 8.8.x too because the translation should exist already.

Committed and pushed 75df2611dc to 9.0.x and 98e9cbc3d7 to 8.9.x and 7fb03ff961 to 8.8.x. Thanks!

As a follow-up idea I think we could add an assert to \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() that if $string is one word then $options['context'] must be set.

  • alexpott committed 75df261 on 9.0.x
    Issue #3064523 by andypost, Kartagis, Sutharsan: Add t() context to "...

  • alexpott committed 98e9cbc on 8.9.x
    Issue #3064523 by andypost, Kartagis, Sutharsan: Add t() context to "...

  • alexpott committed 7fb03ff on 8.8.x
    Issue #3064523 by andypost, Kartagis, Sutharsan: Add t() context to "...
andypost’s picture

@alexpott thank you, nice idea - filed #3108111: Require context for one word translatables

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.