I try to translate the system's e-mail messages. In my case order confirmations in Commerce for Drupal. But the same counts for the messages on account creation, deletion, passwords etc. And lots of other strings. I.E. the billing page states Billing information.

I can find these strings on https://localize.drupal.org/translate/languages/nl/translate.
But when I use Localization client I cant find these strings.

Do I do something wrong?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Localization client shows strings on the page that were used in translation on the page. Eg. emails were sent in the same page request. Which page do you expect these strings to show up and do you think those strings have been used in translation on that page?

ecvandenberg’s picture

FileSize
40.02 KB

Attached you find a screenshot where I edit a system action to send an e-mail. The system's interface is translated to Dutch but not for 100%. I.e. the string The mail's from address. Leave it empty to use the site-wide configured address. When I enter the first few words in Localization client,it does not find this string.

When I search for this string in /admin/config/regional/translate/translate I'm able to translate is. So it is a translatable string.

I now understand that the content of the e-mail messages are not translatable strings. But I can find these e-mail messages on https://localize.drupal.org/translate/languages/nl/translate. Obviously that is a different process Where localization client can not help.

Gábor Hojtsy’s picture

Hum. Even when you translate this string, it keeps appearing in English?

Also can you search for a shorter part of the text, eg. "The mail"?

ecvandenberg’s picture

I tried translating the string at /admin/config/regional/translate/translate. That worked fine. In order to show you the issue, I removed the translation again.

When I search for a shorter part of text in Localization client I do get results that show green or white. So all seems to work fine. But it can't find this string. If i.e. I search for the word mail it finds a couple of strings but not the one I search for.

You are very welcome to see for yourself if you would like so. You can create an account, and I can give you the appropriate access rights. It is a test site.

Gábor Hojtsy’s picture

Title: Translation of e-mail messages » "The mail's from address..." string not showing among list of strings

Yeah I'm not sure why would this string not show among the strings, if when translated elsewhere on the locale UI it shows translated here. That translation itself would put it into the list for l10n_client. Retitled the issue for the problem at hand.

Gábor Hojtsy’s picture

Issue summary: View changes

Missing lots of other strings also

paolomainardi’s picture

Issue summary: View changes

Yes, i guess the problem is related to drupal_static_reset('locale'), i'm facing out the same problem, a lot of strings are missing.

alberto56’s picture

Status: Active » Needs review
FileSize
622 bytes

I had the same problem in #2255047: Some strings do not appear in the l10n_client interface: how to debug?, which I set to a duplicate of this one.

Here is a possible solution:

(1) make this module heavier so its page alter hook is executed later than others (enclosed patch).
(2) if you have strings in a preprocess function (which, i think, is called after all page alter hooks), then you can also add the same t() function to a page alter hook in your module (which has a lighter weight than l10n_client), like this:

/**
 * Use l10n_client module to show strings in the template preprocess.
 *
 * See https://drupal.org/node/2115795
 */
function MYMODULE_page_alter(&$page) {
  t('My String');
}
alberto56’s picture

Status: Needs review » Needs work

Oops. We also need to set the weight in the hook_install().

Also, I'm wondering if we add our strings even later in the page building process, perhaps in a preprocess function rather than a page alter?

alberto56’s picture

Category: Support request » Bug report
Status: Needs work » Needs review
FileSize
1.19 KB

I'm setting this to a bug report because I can systematically exclude strings by placing the t() function in theme or module preprocess hooks, or anywhere else before hook_init() is called.

I have concluded that the module weight is not the issue. Rather, when drupal_static_reset('locale') is called in the hook_init(), it is too late for many strings.

In this patch I have moved drupal_static_reset('locale') from hook_init() to hook_boot(), which does the trick for me: all my strings are now included on the page.

Cheers,

Albert.

alberto56’s picture

Status: Needs review » Needs work

Setting back to needs work. The above patch shows the desired string, but also shows all other translated strings, even those which are not on the page...

This would be a good candidate for an automated test.

alberto56’s picture

Here I added a failing test which demonstrates the problem.

I'll set to "needs review", just to make sure the testbot picks it up and sets it back to "needs work".

alberto56’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
alberto56’s picture

Status: Needs work » Needs review
FileSize
8.53 KB

Failed, that's normal.

In this patch I am remembering preprocess hooks which were called before hook_init() and calling them again at the end of hook_init(). This causes the new automated test to pass.

Status: Needs review » Needs work
alberto56’s picture

Status: Needs work » Needs review
FileSize
6.22 KB

Please ignore the previous patches, they weren't working correctly. Here is a patch which should have two failures: it should be ignoring strings which are translated in the test module's preprocess hook.

Status: Needs review » Needs work
Nicolas Bouteille’s picture

I also noticed that the string "Global tokens will be replaced with their respective token values (e.g. [site:name] or [current-page:title])." form the text format fieldset of any text filtered field does not appear in localization client whereas it does appear in the admin translate interface. So that can also be something to verify when testing your patch.

alberto56’s picture

Thanks. I'm actually not sure that these are all the same problem. I could reliably reproduce the fact that strings which are translated in preprocess hook do not appear. But I imagine that the string to which you are referring is not in a preprocess hook. These might be two different issues...

jiv_e’s picture

I had some problems with view titles not showing up in the Localization client, but the problem went away when I disabled the view's cache or optionally cleared the page cache.

Just noting that caching can also cause issues if someone has these problems.