0

I'm using Drupal 7 and I have a Global: Custom Text in my view

<div class="myclass">
  <h3>Label</h3>
  <div class="title">[title]</div>
  <div class="category">[category]</div> 
</div>

When I try to translate the 'Label' from

`Configuration » Regional and language » Translate interface` 

I get an error 'The submitted string contains disallowed HTML'. That is because the label is wrapped in a div. I could add the div in include/locale.inc in the function

`locale_string_is_safe($string)`

but I don't think is a good idea to edit the Drupal core.

Do you have any better solution?

0

You can create a template for the field, i.e.

views-view-field--your-view-name--nothing.tpl.php

in which, instead of the default code:

print $output;

you add the following code:

$yourstr = t('Your Cool Label');
$out = str_replace('Your Cool Label', $yourstr, $output);
print $out;

In this way you'll find "Your Cool Label" under the translatable strings interface (admin/config/regional/translate/translate).

Just remember to "Rescan template files" under Theme -> Information of your view, then save.

0

Use hook_views_pre_view and set your global header programmatically. E.g.

$view->set_item_option($view->current_display, 'header', 'area_text_custom', 'content', $header);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.