Hi,

A context must be added when calling the function t() because some translatable strings are incorrectly translated due to the lack of context:

E.g. "from" is translated into French as "expéditeur" which is valid only in an e-mail context.

If a context is specified when calling t() like :
t('from', array(), array('context' => 'office_hours')) instead of t('from'), the translation issue can be resolved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

basillic’s picture

In other words, adding a context when calling the function t () allows translators to specify alternative translations.

basillic’s picture

Issue summary: View changes
johnv’s picture

I've fixed the texts in the widget. And some other.
I've added French to my system and tested it.
It now looks like this:

Dimanche de 01:00 jusqu'à 02:00
et de 03:00 jusqu'à 04:00
Lundi de 01:00 jusqu'à 02:00
Rajouter

So I don't see "expéditeur".
Can your try again?
Perhaps are using another contrib module, that overwrites this word?

johnv’s picture

Status: Active » Postponed (maintainer needs more info)

  • johnv committed d15b2d8 on 7.x-1.x
    Issue #2212715 by johnv: Fix translations a.o. by adding context.
    
johnv’s picture

-deleted-

basillic’s picture

On a fresh install with French language enabled :

  1. git clone --branch 7.x-1.x http://git.drupal.org/project/office_hours.git
  2. drush dl date
  3. drush en office_hours -y
  4. drush l10n-update-refresh
  5. drush l10n-update

'From' is not translated. Should be "de".
'Until' is translated by "jusqu'à" which is not the better translation : "à" is a better choice.

With this patch, I think a correct translation may be provided for each language.

  • johnv committed 60949d5 on 7.x-1.x
    Issue #2212715: Added context to functions t() in widget.
    
johnv’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Status: Postponed (maintainer needs more info) » Fixed

In adjacent patch:
- 'Until' is changed to 'To'
- context is added. I thought is would prevant automatic translations, but that seems not to be the case.
- used other function to get lower case, so 'to' translates to 'à', not 'À'.

The word 'From' is automatich translated in my system, but I have some more (basic) modules enabled.

Status: Fixed » Closed (fixed)

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

johnv’s picture

Status: Closed (fixed) » Active

I am not happy with the current approach.

1. A general remark: when setting up a new environment with Drupal 7.x, no translations are downloaded. You need to download a translation yourself:
#2306007: Enable Localization Update to install versions of .po translation files that are older than installed versions of modules/core

2. We have a dependency on DATE_API. It seems that some texts are in DATE module not in DATE_API submodule

3. a translation context for 'day_name' is added. But is is obsolete: #1021424: Use of t() context for month and day names . Day names are in Core, not in Date.

4. The words 'From' and 'To' are translated using complicated algorithms.
- for From: use "starting from @isodate" or remove the word
- for To: use "@from to @to "

  • johnv committed 5ab4c65 on 7.x-1.x
    Issue #2212715: Remove context day_name for t(dayname)
    

  • johnv committed 8e917f0 on 7.x-1.x
    Issue #2212715: Use generic texts, to support all languages...
johnv’s picture

Version: 7.x-1.3 » 8.x-1.x-dev
Status: Active » Patch (to be ported)

  • johnv committed 1c40271 on 8.x-1.x
    Issue #2212715: Use generic texts, to support all languages
    
  • johnv committed 49638dc on 8.x-1.x
    Issue #2212715: Remove context day_name for t(dayname)
    
johnv’s picture

Version: 8.x-1.x-dev » 7.x-1.4
Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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