[ticket/17191] Add new direction and user_langto helper and language.php

PHPBB3-17191
This commit is contained in:
Christian Schnegelberger 2023-09-21 17:00:37 +02:00 committed by Marc Alexander
parent 06f38a5646
commit 6d07852410
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 38 additions and 10 deletions

View file

@ -3668,7 +3668,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true) function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true)
{ {
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path, $language_helper; global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path;
if (defined('HEADER_INC')) if (defined('HEADER_INC'))
{ {
@ -3824,6 +3824,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
$web_path = $phpbb_path_helper->get_web_root_path(); $web_path = $phpbb_path_helper->get_web_root_path();
// Send a proper content-language to the output // Send a proper content-language to the output
// Get the language helper
/* @var $language_helper \phpbb\language\language_file_helper */
$language_file_helper = $phpbb_container->get('language.helper.language_file'); $language_file_helper = $phpbb_container->get('language.helper.language_file');
// Grab the users lang direction and store it for later use // Grab the users lang direction and store it for later use

View file

@ -69,6 +69,16 @@ function adm_page_header($page_title)
$phpbb_version_parts = explode('.', PHPBB_VERSION, 3); $phpbb_version_parts = explode('.', PHPBB_VERSION, 3);
$phpbb_major = $phpbb_version_parts[0] . '.' . $phpbb_version_parts[1]; $phpbb_major = $phpbb_version_parts[0] . '.' . $phpbb_version_parts[1];
// Get the language helper
/* @var $language_helper \phpbb\language\language_file_helper */
$language_file_helper = $phpbb_container->get('language.helper.language_file');
// Grab the users lang direction and store it for later use
$direction = $language_file_helper->get_lang_key_value('direction');
// Get the user_lang string
$user_lang = $language_file_helper->get_lang_key_value('user_lang');
$template->assign_vars(array( $template->assign_vars(array(
'PAGE_TITLE' => $page_title, 'PAGE_TITLE' => $page_title,
'USERNAME' => $user->data['username'], 'USERNAME' => $user->data['username'],
@ -109,11 +119,11 @@ function adm_page_header($page_title)
'ICON_SYNC_DISABLED' => '<i class="icon acp-icon acp-icon-disabled fa-refresh fa-fw" title="' . $user->lang('RESYNC') . '"></i>', 'ICON_SYNC_DISABLED' => '<i class="icon acp-icon acp-icon-disabled fa-refresh fa-fw" title="' . $user->lang('RESYNC') . '"></i>',
'S_USER_ID' => $user->data['user_id'], 'S_USER_ID' => $user->data['user_id'],
'S_USER_LANG' => $user->lang['USER_LANG'], 'S_USER_LANG' => $user_lang,
'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_DIRECTION' => $direction,
'S_CONTENT_ENCODING' => 'UTF-8', 'S_CONTENT_ENCODING' => 'UTF-8',
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', 'S_CONTENT_FLOW_BEGIN' => ($direction == 'ltr') ? 'left' : 'right',
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', 'S_CONTENT_FLOW_END' => ($direction == 'ltr') ? 'right' : 'left',
'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false, 'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false,
)); ));

View file

@ -253,11 +253,19 @@ class helper
*/ */
protected function page_header($page_title, $selected_language = false) protected function page_header($page_title, $selected_language = false)
{ {
global $phpbb_container;
// Path to templates // Path to templates
$paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path); $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path);
$paths = array_filter($paths, 'is_dir'); $paths = array_filter($paths, 'is_dir');
$path = array_shift($paths); $path = array_shift($paths);
$path = substr($path, strlen($this->phpbb_root_path)); $path = substr($path, strlen($this->phpbb_root_path));
// Get the language helper
/* @var $language_helper \phpbb\language\language_file_helper */
$language_file_helper = $phpbb_container->get('language.helper.language_file');
// Grab the users lang direction and store it for later use
$direction = $language_file_helper->get_lang_key_value('direction');
$this->template->assign_vars(array( $this->template->assign_vars(array(
'L_CHANGE' => $this->language->lang('CHANGE'), 'L_CHANGE' => $this->language->lang('CHANGE'),
@ -271,13 +279,13 @@ class helper
'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style',
'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets', 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets',
'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), 'S_CONTENT_DIRECTION' => $direction,
'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', 'S_CONTENT_FLOW_BEGIN' => ($direction === 'ltr') ? 'left' : 'right',
'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', 'S_CONTENT_FLOW_END' => ($direction === 'ltr') ? 'right' : 'left',
'S_CONTENT_ENCODING' => 'UTF-8', 'S_CONTENT_ENCODING' => 'UTF-8',
'S_LANG_SELECT' => $selected_language, 'S_LANG_SELECT' => $selected_language,
'S_USER_LANG' => $this->language->lang('USER_LANG'), 'S_USER_LANG' => $language_file_helper->get_lang_key_value('user_lang'),
)); ));
$this->render_navigation(); $this->render_navigation();

View file

@ -404,8 +404,16 @@ class language
*/ */
public function get_plural_form($number, $force_rule = false) public function get_plural_form($number, $force_rule = false)
{ {
global $phpbb_container;
// Get the language helper
/* @var $language_helper \phpbb\language\language_file_helper */
$language_file_helper = $phpbb_container->get('language.helper.language_file');
// Grab the users lang plural rule
$plural_rule_content = $language_file_helper->get_lang_key_value('plural_rule');
$number = (int) $number; $number = (int) $number;
$plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1); $plural_rule = ($force_rule !== false) ? $force_rule : ((isset($plural_rule_content)) ? $plural_rule_content : 1);
/** /**
* The following plural rules are based on a list published by the Mozilla Developer Network * The following plural rules are based on a list published by the Mozilla Developer Network