本文整理匯總了PHP中Translatable::set_allowed_locales方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translatable::set_allowed_locales方法的具體用法?PHP Translatable::set_allowed_locales怎麽用?PHP Translatable::set_allowed_locales使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translatable
的用法示例。
在下文中一共展示了Translatable::set_allowed_locales方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tearDown
public function tearDown()
{
MultilingualRootURLController::set_use_locale_url($this->origLocaleRoutingEnabled);
Translatable::set_current_locale($this->origCurrentLocale);
Translatable::set_default_locale($this->origLocale);
Translatable::set_allowed_locales($this->origAllowedLocales);
i18n::set_locale($this->origi18nLocale);
Cookie::force_expiry('language');
if ($this->origCookieLocale) {
Cookie::set('language', $this->origCookieLocale);
}
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $this->origAcceptLanguage;
MultilingualRootURLController::reset();
parent::tearDown();
}
開發者ID:helpfulrobot,項目名稱:webbuilders-group-silverstripe-translatablerouting,代碼行數:15,代碼來源:MultilingualControllerTest.php
示例2: testCanTranslate
function testCanTranslate()
{
$origAllowedLocales = Translatable::get_allowed_locales();
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
$testPage = $this->objFromFixture('Page', 'testpage_en');
$this->assertTrue($testPage->canTranslate($cmseditor, 'de_DE'), "Users with canEdit() permission can create a new translation if locales are not limited");
Translatable::set_allowed_locales(array('ja_JP'));
$this->assertTrue($testPage->canTranslate($cmseditor, 'ja_JP'), "Users with canEdit() permission can create a new translation if locale is in Translatable::get_allowed_locales()");
$this->assertFalse($testPage->canTranslate($cmseditor, 'de_DE'), "Users with canEdit() permission can't create a new translation if locale is not in Translatable::get_allowed_locales()");
$this->assertType('Page', $testPage->createTranslation('ja_JP'));
try {
$testPage->createTranslation('de_DE');
$this->setExpectedException("Exception");
} catch (Exception $e) {
}
Translatable::set_allowed_locales($origAllowedLocales);
}
示例3: array
<?php
LeftAndMain::require_css('express/css/custom.css');
SiteTree::add_extension('ExpressSiteTree');
ContentController::add_extension('ExpressSiteTree_Controller');
SiteConfig::add_extension('CustomSiteConfig');
// Don't allow h1 in the editor
HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats', 'p,pre,address,h2,h3,h4,h5,h6');
// Add in start and type attributes for ol
HtmlEditorConfig::get('cms')->setOption('extended_valid_elements', 'img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],iframe[src|name|width|height|title|align|allowfullscreen|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt],ol[start|type]');
// Macrons
HtmlEditorConfig::get('cms')->enablePlugins(array('ssmacron' => '../../../framework/thirdparty/tinymce_ssmacron/editor_plugin_src.js'));
HtmlEditorConfig::get('cms')->insertButtonsAfter('charmap', 'ssmacron');
GD::set_default_quality(90);
FulltextSearchable::enable();
// Configure document converter.
if (class_exists('DocumentConverterDecorator')) {
DocumentImportIFrameField_Importer::set_docvert_username('ss-express');
DocumentImportIFrameField_Importer::set_docvert_password('hLT7pCaJrYVz');
DocumentImportIFrameField_Importer::set_docvert_url('http://docvert.silverstripe.com:8888/');
Page::add_extension('DocumentConverterDecorator');
}
// Default translations
if (class_exists('Translatable')) {
Translatable::set_default_locale('en_NZ');
Translatable::set_allowed_locales(array('en_NZ', 'mi_NZ', 'zh_cmn', 'en_GB'));
SiteTree::add_extension('Translatable');
SiteConfig::add_extension('Translatable');
}
Config::inst()->update('i18n', 'common_locales', array("mi_NZ" => array(0 => 'Māori')));
Config::inst()->update('i18n', 'common_languages', array("mi" => array(0 => 'Māori')));
示例4: testLocalesForMember
function testLocalesForMember()
{
$origAllowedLocales = Translatable::get_allowed_locales();
Translatable::set_allowed_locales(array('de_DE', 'ja_JP'));
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
$translator = $this->objFromFixture('Member', 'germantranslator');
$this->assertEquals(array('de_DE', 'ja_JP'), singleton('SiteTree')->getAllowedLocalesForMember($cmseditor), 'Members with TRANSLATE_ALL permission can edit all locales');
$this->assertEquals(array('de_DE'), singleton('SiteTree')->getAllowedLocalesForMember($translator), 'Members with TRANSLATE_<locale> permission cant edit all locales');
Translatable::set_allowed_locales($origAllowedLocales);
}
示例5:
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
// Use _ss_environment.php file for configuration
require_once "conf/ConfigureFromEnv.php";
// Register custom site configuration extension
DataObject::add_extension('SiteConfig', 'CustomSiteConfig');
// Set the site locale
i18n::set_locale('en_US');
//Turn on Silverstripe Translation
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');
Translatable::set_allowed_locales(array('en_US', 'de_DE', 'es_ES', 'ja_JP'));
//Turn on Silverstripe Translation
// Search index for Orgs
Object::add_extension('Org', 'AutocompleteOrgDecorator');
// Enable SSL for specific subdomains
if (Director::isLive()) {
Director::forceSSL(array('/^Security/', '/^profile/', '/^join/', '/^user-survey/', '/^summit/', '/^news-manage/', '/^vote-vancouver/'));
}
// Email errors and warnings
global $email_log;
SS_Log::add_writer(new SS_LogFileWriter(Director::baseFolder() . '/logs/site.log'), SS_Log::ERR);
$email_log_writer = new Custom_SS_LogEmailWriter($email_log);
$email_log_writer->setFormatter(new SS_CustomLogErrorEmailFormatter());
SS_Log::add_writer($email_log_writer, SS_Log::ERR, '<=');
// Default From address for email
global $email_from;