我正在构建一个使用ar和en语言的网站,根据silverstripe docs here,我完成了文本收集过程并取得了成功。但在我当前主题的lang文件夹中只创建了一个en.yaml文件。应该有另一个ar.yaml文件!。
这是我的_config.php文件:
<?php
global $project;
$project = 'mysite';
FulltextSearchable::enable();
global $databaseConfig;
$databaseConfig = array(
'type' => 'MySQLDatabase',
'server' => 'localhost',
'username' => 'dbuser',
'password' => '123',
'database' => 'cont_learning_2',
'path' => ''
);
// Set the site locale
i18n::set_locale('ar_EG');
Director::set_environment_type('dev');
if(!Director::isDev()) {
// log errors and warnings
SS_Log::add_writer(new SS_LogFileWriter('../silverstripe-errors-warnings.log'), SS_Log::WARN, '<=');
// or just errors
SS_Log::add_writer(new SS_LogFileWriter('../silverstripe-errors.log'), SS_Log::ERR);
// or notices (e.g. for Deprecation Notifications)
SS_Log::add_writer(new SS_LogFileWriter('../silverstripe-errors-notices.log'), SS_Log::NOTICE);
}
Security::setDefaultAdmin('admin','admin');
// multi-language configuration - translatable module
Translatable::set_default_locale('ar_EG');
Translatable::set_allowed_locales(array(
'ar_EG',
'en_US',
));
SiteTree::add_extension('Translatable');
答案 0 :(得分:2)
文本收集器任务不知道您的安装将/可能具有的可能的语言环境。所以它基本上只收集所有字符串并将它们放在默认的yml文件中。
如果您有en.yml
个文件,请将其复制为ar.yml
,确保以ar:
而不是en:
开头,并将所有文字翻译为阿拉伯文。
答案 1 :(得分:1)
使用https://github.com/Zauberfisch/silverstripe-better-i18n,您可以在一项任务中创建和更新不同的语言。您可以使用composer将其安装为仅开发需求。
我像
一样运行它http://localhost/dev/tasks/BetterI18nTextCollectorTask?module=mysite,themes/my-theme&targetlocale=de,en
在 mysite 和 themes / my-theme 中创建德语和英语yml文件。
它将创建一系列带有双下划线(作为伪注释)的项目,以及数据库字段的默认键。