Drupal: how can I add transable text from my php template?
I'm using Drupal with international module for translations.
how can I add transable text from php template to my website ?
In other terms, I've customized my website adding some fixed content directly from php code. However I would like this content to appear as st开发者_高级运维ring in the languages translation search.
I've added this but it doesn't work so far (I've also refreshed the translation database):
<?php echo t('Some random description here, a bit longer ok. Some random description here.'); ?>
thanks
You need to visit the translated content at least once to add such strings to the translation interface.
In drupal, all text that should be translated has to go through the t() function. You can access this function in your template as well, assuming you're using a PHPTemplate-based theme. Read the documentation for the t() function for the various ways to include variables in translatable strings. It also covers good practices to make things easier for your translators.
Here's an example of how to replace some text in your template to make it translatable:
Before:
<p class="example">
This is example text.
</p>
After:
<p class="example">
<?php print t("This is example text."); ?>
</p>
It is important to visit page when using non-default language. See https://www.drupal.org/node/1496740 for more info.
精彩评论