2

How do I translate a custom module theme file?

function bonds_graph_theme($existing, $type, $theme, $path)
{
    $items = array();

    $items[BONDS_GRAPH_MODULE_NAME] = array(
   'arguments' => array(),
   'file' => 'inc/theme.inc',
   'template' => 'tpl/bonds_graph',
 );

return $items;
}

The theme file has a translatable string

<?php print date('Y') . ' ' . t('Issuance'); ?>    

The language file zh-hans.po has the translation

#: tpl/bonds_graph.tpl.php:7
msgid "Issuance"
msgstr "发行"  

The site language is set. How do I get the string translated?

1 Answer 1

4

The .po file must be located in custom_module/translations directory - see locale_batch_by_component function. Translation file though is only imported once module gets installed, so in case you want to reimport the file you would have to run some "hacky" drush command, such as drush php-eval "locale_system_update(array('custom_module'));drush_backend_batch_process();"

You can also upload .po file manually using Drupal's admin UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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