开发者

drupal translation t() function doesn't do anything...outputs the same text

开发者 https://www.devze.com 2023-02-19 14:33 出处:网络
I\'ve read that using the t(\'text to translate\') I can translate texts in drupal templates.The problem is, this function doesn\'t do anything. It simply outputs the same text.

I've read that using the t('text to translate') I can translate texts in drupal templates. The problem is, this function doesn't do anything. It simply outputs the same text.

I already have a site and I have installed the proper modul开发者_C百科es so that's not the problem.

I am using this to translate the titles for the blocks in block.tpl.php.

<h2><?php print t($block->subject); ?></h2>

So this outputs the same original text i'm defining in the title of the view as the block. Why? If I had an error shouldn't Drupal output something or log that error at least?


Translation is not magic. You also need to set up the language of your site in something else than english and be sure that the string you display have a translation.

You can check this at this page : exemple.com/?q=admin/build/translate/search (d6 url)


for the t function to work, you have to do the following:

  1. enable the optional core modules called locale (for interface items) and optionally the content translation (for content).
  2. grant the proper permissions for the proper roles
  3. go to site building -> translate interface to access the interface translation page.

hope that helps

-peter


The translation is not being displayed because its not there. You need to add the translation of that particular string, only then the translated string would be rendered. If you have all the required modules in place, then you need to go to "admin/config/regional/translate/translate" and then search for your string; then click on edit and add the translation of that string.


You also need to install the Locale module and provide translations in the languages you want to support.

0

精彩评论

暂无评论...
验证码 换一张
取 消