Ale*_*ber 17 localization drupal gettext internationalization drupal-7
我使用的是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') {
....
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我需要所有字符串都是俄语,并且不想将它们硬编码到我的game.module文件中.
我是否需要创建名为game.po的第3个文件并将其添加到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
Run Code Online (Sandbox Code Playgroud)
cor*_*cho 22
这应该是步骤:
要生成.pot文件,请安装模块Translation模板提取程序
转到Locale管理界面上的" Extract strings "选项卡,选择您的模块并提交表单.您将获得一个生成的模板文件.
然后你可以使用像Poedit(http://www.poedit.net)这样的工具翻译字符串.
完成后,应将文件复制到模块文件夹中的"翻译"子文件夹,以便在安装游戏模块时由Drupal自动导入.
请提供反馈并告诉您有什么问题.谢谢
| 归档时间: |
|
| 查看次数: |
16072 次 |
| 最近记录: |