mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #6534 from Crizz0/ticket/17191
[ticket/17191] New config values to language/en/composer.json
This commit is contained in:
commit
9ec60b4523
9 changed files with 73 additions and 24 deletions
|
@ -3849,7 +3849,7 @@ 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
|
||||||
$user_lang = $user->lang['USER_LANG'];
|
$user_lang = $user->lang('USER_LANG');
|
||||||
if (strpos($user_lang, '-x-') !== false)
|
if (strpos($user_lang, '-x-') !== false)
|
||||||
{
|
{
|
||||||
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
|
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
|
||||||
|
@ -3955,6 +3955,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||||
'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'],
|
'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'],
|
||||||
'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'],
|
'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'],
|
||||||
'L_ONLINE_EXPLAIN' => $l_online_time,
|
'L_ONLINE_EXPLAIN' => $l_online_time,
|
||||||
|
'L_RECAPTCHA_LANG' => $user->lang('RECAPTCHA_LANG'),
|
||||||
|
|
||||||
'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
||||||
'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
||||||
|
@ -3995,9 +3996,9 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||||
'S_USER_LANG' => $user_lang,
|
'S_USER_LANG' => $user_lang,
|
||||||
'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],
|
'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],
|
||||||
'S_USERNAME' => $user->data['username'],
|
'S_USERNAME' => $user->data['username'],
|
||||||
'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
|
'S_CONTENT_DIRECTION' => $user->lang('DIRECTION'),
|
||||||
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
|
'S_CONTENT_FLOW_BEGIN' => ($user->lang('DIRECTION') == 'ltr') ? 'left' : 'right',
|
||||||
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
'S_CONTENT_FLOW_END' => ($user->lang('DIRECTION') == 'ltr') ? 'right' : 'left',
|
||||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||||
'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name),
|
'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name),
|
||||||
'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0,
|
'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0,
|
||||||
|
|
|
@ -109,11 +109,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('USER_LANG'),
|
||||||
'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
|
'S_CONTENT_DIRECTION' => $user->lang('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' => ($user->lang('DIRECTION') == 'ltr') ? 'left' : 'right',
|
||||||
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
'S_CONTENT_FLOW_END' => ($user->lang('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,
|
||||||
));
|
));
|
||||||
|
|
|
@ -37,10 +37,6 @@ if (empty($lang) || !is_array($lang))
|
||||||
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
|
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
|
||||||
|
|
||||||
$lang = array_merge($lang, [
|
$lang = array_merge($lang, [
|
||||||
// Find the language/country code on https://developers.google.com/recaptcha/docs/language
|
|
||||||
// If no code exists for your language you can use "en" or leave the string empty
|
|
||||||
'RECAPTCHA_LANG' => 'en-GB',
|
|
||||||
|
|
||||||
'CAPTCHA_RECAPTCHA' => 'reCaptcha v2',
|
'CAPTCHA_RECAPTCHA' => 'reCaptcha v2',
|
||||||
'CAPTCHA_RECAPTCHA_V3' => 'reCaptcha v3',
|
'CAPTCHA_RECAPTCHA_V3' => 'reCaptcha v3',
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,8 @@ if (empty($lang) || !is_array($lang))
|
||||||
|
|
||||||
$lang = array_merge($lang, array(
|
$lang = array_merge($lang, array(
|
||||||
'TRANSLATION_INFO' => '',
|
'TRANSLATION_INFO' => '',
|
||||||
'DIRECTION' => 'ltr',
|
|
||||||
'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007 (with Relative days enabled)
|
'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007 (with Relative days enabled)
|
||||||
'DATETIME_FORMAT' => '|d M Y, H:i|', // 01 Jan 2007, 13:37 (with Relative days enabled)
|
'DATETIME_FORMAT' => '|d M Y, H:i|', // 01 Jan 2007, 13:37 (with Relative days enabled)
|
||||||
'USER_LANG' => 'en-gb',
|
|
||||||
|
|
||||||
// You can define different rules for the determination of plural forms here.
|
|
||||||
// See https://area51.phpbb.com/docs/dev/3.3.x/language/plurals.html for more information
|
|
||||||
// or ask the translation manager for help.
|
|
||||||
'PLURAL_RULE' => 1,
|
|
||||||
|
|
||||||
'1_DAY' => '1 day',
|
'1_DAY' => '1 day',
|
||||||
'1_MONTH' => '1 month',
|
'1_MONTH' => '1 month',
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
"language-iso": "en",
|
"language-iso": "en",
|
||||||
"english-name": "British English",
|
"english-name": "British English",
|
||||||
"local-name": "British English",
|
"local-name": "British English",
|
||||||
"phpbb-version": "4.0.0-a1-dev"
|
"phpbb-version": "4.0.0-a1-dev",
|
||||||
|
"direction": "ltr",
|
||||||
|
"user-lang": "en-gb",
|
||||||
|
"plural-rule": 1,
|
||||||
|
"recaptcha-lang": "en-GB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ class feed
|
||||||
'FEED_TITLE' => $this->config['sitename'],
|
'FEED_TITLE' => $this->config['sitename'],
|
||||||
'FEED_SUBTITLE' => $this->config['site_desc'],
|
'FEED_SUBTITLE' => $this->config['site_desc'],
|
||||||
'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time),
|
'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time),
|
||||||
'FEED_LANG' => $this->user->lang['USER_LANG'],
|
'FEED_LANG' => $this->language->lang('USER_LANG'),
|
||||||
'FEED_AUTHOR' => $this->config['sitename'],
|
'FEED_AUTHOR' => $this->config['sitename'],
|
||||||
|
|
||||||
// Feed entries
|
// Feed entries
|
||||||
|
|
|
@ -384,10 +384,27 @@ class language
|
||||||
$this->load_core_file($lang_file);
|
$this->load_core_file($lang_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->inject_default_variables();
|
||||||
|
|
||||||
$this->common_language_files_loaded = true;
|
$this->common_language_files_loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject default values based on composer.json
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function inject_default_variables(): void
|
||||||
|
{
|
||||||
|
$lang_values = $this->loader->get_composer_lang_values($this->language_fallback);
|
||||||
|
|
||||||
|
$this->lang['DIRECTION'] = $lang_values['direction'] ?? 'ltr';
|
||||||
|
$this->lang['USER_LANG'] = $lang_values['user_lang'] ?? 'en-gb';
|
||||||
|
$this->lang['PLURAL_RULE'] = $lang_values['plural_rule'] ?? 1;
|
||||||
|
$this->lang['RECAPTCHA_LANG'] = $lang_values['recaptcha_lang'] ?? 'en-GB';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine which plural form we should use.
|
* Determine which plural form we should use.
|
||||||
*
|
*
|
||||||
|
@ -404,7 +421,7 @@ class language
|
||||||
public function get_plural_form($number, $force_rule = false)
|
public function get_plural_form($number, $force_rule = false)
|
||||||
{
|
{
|
||||||
$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($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 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
|
||||||
|
|
|
@ -30,7 +30,8 @@ class language_file_helper
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $phpbb_root_path Path to phpBB's root
|
* @param string $phpbb_root_path Path to phpBB's root
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct(string $phpbb_root_path)
|
public function __construct(string $phpbb_root_path)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +92,7 @@ class language_file_helper
|
||||||
*/
|
*/
|
||||||
protected function get_language_data_from_json(array $data) : array
|
protected function get_language_data_from_json(array $data) : array
|
||||||
{
|
{
|
||||||
if (!isset($data['extra']['language-iso']) || !isset($data['extra']['english-name']) || !isset($data['extra']['local-name']))
|
if (!isset($data['extra']['language-iso']) || !isset($data['extra']['english-name']) || !isset($data['extra']['local-name']) || !isset($data['extra']['direction']) || !isset($data['extra']['user-lang']) || !isset($data['extra']['plural-rule']) || !isset($data['extra']['recaptcha-lang']))
|
||||||
{
|
{
|
||||||
throw new DomainException('INVALID_LANGUAGE_PACK');
|
throw new DomainException('INVALID_LANGUAGE_PACK');
|
||||||
}
|
}
|
||||||
|
@ -115,6 +116,10 @@ class language_file_helper
|
||||||
'author' => implode(', ', $authors),
|
'author' => implode(', ', $authors),
|
||||||
'version' => $data['version'],
|
'version' => $data['version'],
|
||||||
'phpbb_version' => $data['extra']['phpbb-version'],
|
'phpbb_version' => $data['extra']['phpbb-version'],
|
||||||
|
'direction' => $data['extra']['direction'],
|
||||||
|
'user_lang' => $data['extra']['user-lang'],
|
||||||
|
'plural_rule' => $data['extra']['plural-rule'],
|
||||||
|
'recaptcha_lang'=> $data['extra']['recaptcha-lang'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,39 @@ class language_file_loader
|
||||||
throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.');
|
throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get language values from composer.json files
|
||||||
|
*
|
||||||
|
* @param array|string $locales
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_composer_lang_values(array|string $locales): array
|
||||||
|
{
|
||||||
|
if (!is_array($locales))
|
||||||
|
{
|
||||||
|
$locales = [$locales];
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_helper = new language_file_helper($this->phpbb_root_path);
|
||||||
|
$composer_lang_vars = $file_helper->get_available_languages();
|
||||||
|
|
||||||
|
foreach ($composer_lang_vars as $key => $value)
|
||||||
|
{
|
||||||
|
$composer_lang_vars[$value['iso']] = $value;
|
||||||
|
unset($composer_lang_vars[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($locales as $locale)
|
||||||
|
{
|
||||||
|
if (isset($composer_lang_vars[$locale]))
|
||||||
|
{
|
||||||
|
return $composer_lang_vars[$locale];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count($composer_lang_vars) ? array_shift($composer_lang_vars) : [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads language file
|
* Loads language file
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue