我正在构建一个使用ar和en语言的网站,根据这里的silverstripe文档,我完成了文本收集过程并取得了成功。但只有一个。Yaml文件在我当前主题的lang文件夹中创建。应该有另一个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');
文本收集器任务不知道您的安装将具有/可能具有的可能的区域设置。它会收集所有字符串并把它们放在一个默认的yml文件中。
如果您有一个en.yml
文件,将其复制为ar.yml
,确保它以ar:
而不是en:
开头,并将所有文本翻译为阿拉伯语
使用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文件。
它将创建一堆以双下划线为前缀的项目(作为伪注释),以及数据库字段的默认键。