我正在使用CentOS 5.5 Linux(不带X),PHP 5.3和Drupal 7.0。

我网站的核心语言是俄语(不是英语)!

我创建了一个game.info和以下game.module,它们为首页生成了3个块:

function game_block_info() {
  return array(
  'game_main' => array(
    'info' => t('Set FlashVars and show the flash game.'),
    'cache' => DRUPAL_NO_CACHE,
  ),
  'game_winner' => array(
    'info' => t('Show the winner of the last week.'),
    'cache' => DRUPAL_NO_CACHE,
  ),
  'game_leader' => array(
    'info' => t('Show the leader of the current week.'),
    'cache' => DRUPAL_NO_CACHE,
  );
}


function game_block_view($block_name = '') {
  global $user;

  if ($block_name == 'game_main') {
    if (user_is_logged_in()) {
      $content = t('User is logged in.');
    } else {
      $content = t('User is an anonymous user.');
    }
    drupal_set_message("<pre>$output</pre>\n");
    return array(
      'subject' => t('Main Game'),
      'content' => $content,
    );
  } else if ($block_name == 'game_winner') {
    ....
  } else if ($block_name == 'game_leader') {
    ....
  }
}


一切正常,但是我需要所有字符串都使用俄语,并且不想将其硬编码到我的game.module文件中。

我需要创建第三个文件game.po并将其添加到game.info吗?

如何创建.po文件?如果可能,我希望对该文件进行简单的编辑,而又不要使用晦涩难懂的工具。

我也尝试了一种工具:

# xgettext -n game/game.module --keyword=t
xgettext: warning: file `game/game.module' extension `module' is unknown; will try C
game/game.module:87: warning: unterminated character constant
game/game.module:100: warning: unterminated character constant

最佳答案

这些应该是步骤:


要生成.pot文件,请安装模块Translation template extractor
转到“区域设置”管理界面上的“提取字符串”选项卡,选择您的模块并提交表单。您将生成一个单个模板文件。
然后,您可以使用Poedit(http://www.poedit.net)之类的工具翻译字符串。
完成后,应将文件复制到模块文件夹中的“ translations”子文件夹中,以便在安装游戏模块时Drupal自动将其导入。


请提供反馈意见,并告诉您您遇到了什么问题。谢谢

关于drupal - 如何为自定义Drupal 7模块生成翻译文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5231496/

10-11 22:24
查看更多