I have i18n's block translation and string translation enabled and translated my text in message but it sticks to the English version and the variable simplenews translate simplenews_block_m_multiple isn't listed under i18n variables either.
How do you translate the multi signup block body message?

Comments

berdir’s picture

Category: support » bug

That variable (and all other which contain strings that need to be translatable) need to be defined in simplenews_variable_info() to show up in i18n variables.

Have a look at http://api.worldempire.ch/api/simplenews/simplenews.module/function/simp..., should be trivial to extend that with additional variables.

The per-category blocks might need a loop similar to the one in hook_block_info() if there are variables which should be translatable, so that we can expose all of them.

Patches are welcome :)

berdir’s picture

Assigned: Unassigned » corvus_ch
miiimooo’s picture

Status: Active » Needs review
StatusFileSize
new480 bytes

Please find attached the patch for review.

miiimooo’s picture

Status: Needs review » Needs work

Follow up: this alone doesn't make the block message in the block configuration form a multi-lingual variable (lie this does for site slogan etc). Maybe the i18n_variable doesn't collaborate well with the block configuration form?

berdir’s picture

Ah, yes, it's is probably not detected by Variable/I18n Variable translation because it's not a system_settings_form() and we are saving the variables manually.

I suggest you look at the form_alters() of these two modules and try to see if you can find a way to enable the same behavior, e.g. be adding something to the form or by calling an API function of those modules manually.

webflo’s picture

Issue tags: +i18n compatibility
danyg’s picture

Status: Needs work » Needs review

The patch works, then You should add 2 lines of code to your theme's template.php and block message is translatable after clearing caches:

function yourthemename_preprocess_simplenews_block(&$vars) {
  // We send the text through t() after we got the apropiate variable
  $vars['message'] = check_plain(t(variable_get('simplenews_block_m_' . $vars['tid'], 'Stay informed on our latest news!')));
}
berdir’s picture

Status: Needs review » Needs work

No, that is the wrong way to do it.

chrbak’s picture

Another quick and more easy way (but not the appropriate one) is to just add the below function in your template.php file :

function yourthemename_preprocess_simplenews_block(&$vars) {
  $vars['message'] = t($vars['message']);
}

Until a clear solution be found.

epageperron’s picture

nm !

clcl’s picture

Hi,
I have added the function in preprocess.html.inc file since I work with Omega theme.
Since I have the newest simplenews module (7.x-1.0) I can not ad the patch #3 who is for the 7.x-1.0-beta2.
Can somebody help me out with this?
Thanks in advance!

clcl’s picture

I saw in the simplenews.module
#default_value' => variable_get('simplenews_block_m_multiple', t('Select the newsletter(s) to which you want to subscribe or unsubscribe.')

I did write in the string translations a translation in dutch and french, but the default t is staying.
Probably it is a broken language link because I changed my default language to dutch. But how to fix this?
Maybe this helps other to find a solution.

shaneonabike’s picture

For me the variables are appearing properly in i18n.

BUT they aren't actually being translated... I think I see the problem though.

simplenews.module (line 2400)

  $variables['message'] = check_plain(variable_get('simplenews_block_m_multiple', t('Select the newsletter(s) to which you want to subscribe or unsubscribe.')));

Is doing one of two things... if no variable is set retrieve the default (translated) value set. But if it's ever been changed then just retrieve that... oops.

Would it be proper to do...

  $message = t(variable_get('simplenews_block_m_multiple', 'Select the newsletter(s) to which you want to subscribe or unsubscribe.'));
  $variables['message'] = check_plain($message);
shaneonabike’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.72 KB

Ok here's the patch. I ran all the translated messages through check_plain to prevent exploits which I *think* is the correct wait to deal with that.

Status: Needs review » Needs work

The last submitted patch, 1458538-translate_multi_signup_block_body_message-14.patch, failed testing.

clcl’s picture

I have tried the changes, but it failed. Is there another solution?

idhard’s picture

The solution #19 works fine. Thanks

ram4nd’s picture

I had a different block, but #9 worked. Although I didn't try to do this with variables.

/**
 * Implements theme_preprocess_simplenews_block().
 *
 * Translate multi signup block body message / i18n
 * https://drupal.org/node/1458538#comment-7389624
 */
function THEME_preprocess_simplenews_multi_block(&$vars) {
  $vars['message'] = t($vars['message']);
}
clcl’s picture

Issue summary: View changes

I have the omega theme and I do not see where to put the code. I tried to put the code in the preproces.html.inc but it does not work.

ram4nd’s picture

The easiest would be to put it in template.php. Do you use omega theme directly? You should create your subtheme, use omega tools for an example.

clcl’s picture

I have made a subtheme. And I have set the code in the template.php. But nothing happened. I changed the name of THEME in Sitranstheme wich is the name of my omega subtheme.
Do I have to do anything else? I do not see a place to translate the text. Although I changed the text into subscribe or unsubscribe on the nl pages.

clcl’s picture

In the main time the problem is solved. The buttons subscribe or unsubscribe are available in the newest version of the newsletter. So I deleted the message for the block and the message is not showing up any more.

clcl’s picture

Version: 7.x-1.x-dev » 7.x-1.1
Status: Needs work » Fixed

The version Simplenews 7.x-1.1 is the solution for the problem 'body message in block not translated.

berdir’s picture

Status: Fixed » Active

There have been no changes, so I don't think this is resolved, keeping open.

happyjoker’s picture

You can go to simplenews-multi-block.tpl and
t() function for $message such as

if ($message):

print t($message);

endif;

If i understand a problem since my English is vey weak

good luck

anybody’s picture

I can confirm this problem still exists and the variable is not translatable yet.

Wtower’s picture

I can confirm this too. Subscribing.

corvus_ch’s picture

Assigned: corvus_ch » Unassigned
dorkmaneuver’s picture

Also confirming - and subscribing. :)

eevvvv’s picture

I can not translate Newsletter categories. I need help. Any advice will be appreciated)