Always translate from English when there is a context

Created on 13 May 2013, over 11 years ago
Updated 1 March 2023, over 1 year ago

We never translate English in 7.x and only translate English in 8.x if the new variable locale_translate_english is set. Shouldn't we translate whenever there is a context?

I have a multilingual site, with only one language for English 'en'. The site uses context's for locality, such that the context might be 'AU' for Australian English. The problem is that t() will not translate English ever, even when there is a context. The only work around I have for this is to force strings to import into a new language, such as en-au or to change core with a patch like the one attached.

This is not a problem for languages like French 'fr' or Portugese 'pt'. In both these cases, rather than have a language 'fr-ca' or 'pt-br', once again, the site uses the base language and passes the country as a context. But since these are not English, core handles these just fine. Why should English be any different than French or Portugese.

We tried to make English non-special in #1266318: Make English a first class language β†’ although I don't think we properly considered contexts.

Attached are patches for both 7.x and 8.x.

πŸ› Bug report
Status

Closed: works as designed

Version

9.5

Component
Language systemΒ  β†’

Last updated 1 day ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

πŸ‡ΊπŸ‡ΈUnited States douggreen Winchester, VA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    This was a daily triage target for bug smash. I'm not entirely sure this is the correct use of contexts, but if it is we need tests, steps to reproduce, a re-roll and an issue summary update. It would be good to see an example of how this is used for fr-ca or pt-br as mentioned in the issue summary.

  • Status changed to Closed: won't fix over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom james.williams

    The context option is not meant for indicating which language (or variant/locale/etc of a language) a string is in. See the Internationalization documentation. It's instead for words like 'view' or 'may' that can mean multiple things in different contexts and so might need translating to different words in different languages. (I think a technical term for these is 'homonyms'?) So, in answer to your question, "Shouldn't we translate whenever there is a context?" - no, context is not a determining factor in whether we should translate.

    As far as Drupal is concerned, any country-specific variant of a language has to be treated as an entirely distinct language. Modules like Language Hierarchy exist to cover that use case, so that you can set up something like en-AU or pt-BR as a separate language, that 'inherits' translations from a 'parent' language, other than those that have been specifically customised for the 'child' language. (Ultimately, these modules are leveraging the hook_language_fallback_candidates_alter() hook in core.) Disclaimer: I'm a maintainer of Language Hierarchy, so of course I'd say this! But I'm primarily a maintainer because I see its usefulness, so I certainly empathise with your need to override strings for a particular 'variant' of a language.

    If there's a bug in allowing English strings to be translated via that translate_english setting in the locale.settings config, then sure, of course that can be looked at, but tests to prove it would indeed be needed.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    After bring this up in #bugmsash, I also ask in #multilingual

    @james.williams, thank you for responding.

    For completeness, The reply given in #21 is the same as the bugsmash discussion by GΓ‘bor Hojtsy, Lendude and mstrelan in bugsmash. Although, the latter concluded this is working as designed. And that does look right to me. Changing status.

Production build 0.71.5 2024