本文整理汇总了PHP中Symfony\Component\Translation\Translator::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::getLocale方法的具体用法?PHP Translator::getLocale怎么用?PHP Translator::getLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Translation\Translator
的用法示例。
在下文中一共展示了Translator::getLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetLocale
public function testSetGetLocale()
{
$translator = new Translator('en', new MessageSelector());
$this->assertEquals('en', $translator->getLocale());
$translator->setLocale('fr');
$this->assertEquals('fr', $translator->getLocale());
}
示例2: editorReplace
/**
* @return string
*/
public function editorReplace()
{
$toolbar = new Toolbar($this->urlGenerator, $this->toolbarSet, $this->config);
$toolbar->setLanguage($this->translator->getLocale());
$config = $toolbar->getConfig();
$javascript = $this->toJavascript($config);
$html = "<script>\n CKEDITOR.replace('" . $this->name . "',\n {$javascript}\n );\n </script>";
return $html;
}
示例3: testSetValidLocale
/**
* @dataProvider getValidLocalesTests
*/
public function testSetValidLocale($locale)
{
$translator = new Translator($locale, new MessageSelector());
$translator->setLocale($locale);
$this->assertEquals($locale, $translator->getLocale());
}
示例4: getLocale
public function getLocale()
{
return $this->translator->getLocale();
}
示例5: setHeaderParameters
/**
* Set header parameters
*/
private function setHeaderParameters()
{
$_course = api_get_course_info();
$_configuration = $this->app->getConfiguration();
$this_section = $this->app['this_section'];
$nameTools = $this->title;
$navigation = $this->navigation_array;
$this->menu_navigation = $navigation['menu_navigation'];
$this->assign('system_charset', api_get_system_encoding());
$this->assign('online_button', Display::return_icon('online.png'));
$this->assign('offline_button', Display::return_icon('offline.png'));
// Get language iso-code for this page - ignore errors
$this->assign('document_language', $this->translator->getLocale());
$course_title = isset($_course['name']) ? $_course['name'] : null;
$title_list = array();
$title_list[] = api_get_setting('platform.institution');
$title_list[] = api_get_setting('platform.site_name');
if (!empty($course_title)) {
$title_list[] = $course_title;
}
if ($nameTools != '') {
$title_list[] = $nameTools;
}
$title_string = '';
for ($i = 0; $i < count($title_list); $i++) {
$title_string .= $title_list[$i];
if (isset($title_list[$i + 1])) {
$item = trim($title_list[$i + 1]);
if (!empty($item)) {
$title_string .= ' - ';
}
}
}
$this->assign('title_string', $title_string);
// Setting the theme and CSS files.
$this->setCssFiles();
$this->setJsFiles();
// Implementation of prefetch.
// See http://cdn.chamilo.org/main/img/online.png for details
$prefetch = '';
if (!empty($_configuration['cdn_enable'])) {
$prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
foreach ($_configuration['cdn'] as $host => $exts) {
$prefetch .= '<link rel="dns-prefetch" href="' . $host . '">';
}
}
$this->assign('prefetch', $prefetch);
$this->assign('text_direction', api_get_text_direction());
$this->assign('section_name', 'section-' . $this_section);
$favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />';
/*if (isset($_configuration['multiple_access_urls']) &&
$_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url_info = api_get_current_access_url_info();
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = api_replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
$homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path
$icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url;
//we create the new dir for the new sites
if (is_file($icon_real_homep.'favicon.ico')) {
$favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />';
}
}
}*/
//$this->assign('favico', $favico);
$this->setHelp();
$notification = $this->returnNotificationMenu();
$this->assign('notification_menu', $notification);
// Profile link.
$this->assign('is_profile_editable', api_is_profile_readable());
$visibility = api_is_allowed_to_create_course() ? \SystemAnnouncementManager::VISIBLE_TEACHER : \SystemAnnouncementManager::VISIBLE_STUDENT;
$announcements = \SystemAnnouncementManager::getAnnouncements($visibility, null, 'resumed', false, 50);
$this->assign('news_counter', count($announcements));
$this->assign('news_list', $announcements);
$profile_link = null;
if (api_get_setting('social.allow_social_tool') == 'true') {
$profile_link = $this->urlGenerator->generate('root') . 'social/home.php';
} else {
if (api_is_profile_readable()) {
$profile_link = $this->urlGenerator->generate('root') . 'auth/profile.php';
}
}
$this->assign('profile_link', $profile_link);
$this->assign('settings_link', $this->urlGenerator->generate('root') . 'auth/profile.php');
// Message link.
$messageUrl = null;
if (api_get_setting('message.allow_message_tool') == 'true') {
$messageUrl = $this->urlGenerator->generate('root') . 'messages/inbox.php';
}
$this->assign('message_link', $messageUrl);
$institution = api_get_setting('platform.institution');
$portal_name = empty($institution) ? api_get_setting('platform.site_name') : $institution;
$this->assign('portal_name', $portal_name);
//.........这里部分代码省略.........