Skip to content

Commit 0cc5453

Browse files
committed
Fix phpBB 4 language system
1 parent d31c946 commit 0cc5453

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

includes/class_qi.php

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,45 @@ public static function get_lang_select($lang_path, $config_var, $get_var = '')
280280
continue;
281281
}
282282

283-
$file = "$lang_path/$lang/iso.txt";
283+
$lang_iso = $lang_path . $lang . DIRECTORY_SEPARATOR . 'iso.txt'; // for phpBB 3.x languages
284+
$lang_composer = $lang_path . $lang . DIRECTORY_SEPARATOR . 'composer.json'; // for phpBB 4.0 languages
284285

285-
if (file_exists($file))
286+
if (file_exists($lang_iso))
286287
{
287-
$rows = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
288-
289-
// Always show the English language name, except for the "active" language.
290-
$lang_options[] = [
291-
'name' => ($lang === $user_lang) ? $rows[1] : $rows[0],
292-
'value' => $lang,
293-
'selected' => $lang === $user_lang,
294-
];
288+
$rows = file($lang_iso, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
289+
290+
$english_name = $rows[0];
291+
$local_name = $rows[1];
292+
}
293+
else if (file_exists($lang_composer))
294+
{
295+
global $phpbb_root_path;
296+
$language_helper = new \phpbb\language\language_file_helper($phpbb_root_path);
297+
298+
try
299+
{
300+
$lang_pack = $language_helper->get_language_data_from_composer_file($lang_composer);
301+
}
302+
catch (\DomainException $e)
303+
{
304+
trigger_error('LANGUAGE_PACK_MISSING', E_USER_WARNING);
305+
}
306+
307+
$english_name = $lang_pack['name'];
308+
$local_name = $lang_pack['local_name'];
295309
}
310+
else
311+
{
312+
// worst case just use the iso name if nothing above worked
313+
$local_name = $english_name = $lang;
314+
}
315+
316+
// Always show the English language name, except for the "active" language.
317+
$lang_options[] = [
318+
'name' => ($lang === $user_lang) ? $local_name : $english_name,
319+
'value' => $lang,
320+
'selected' => $lang === $user_lang,
321+
];
296322
}
297323

298324
return $lang_options;

language/en/qi.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175

176176
'JAVASCRIPT_DISABLED_ALERT' => '<strong>Javascript is disabled!</strong> Please enable Javascript for full functionality.',
177177

178+
'LANGUAGE_PACK_MISSING' => 'The source phpBB board does not have a valid language pack. Please download a fresh copy of phpBB and try again.',
178179
'LOAD' => 'Load',
179180
'LOG_INSTALL_INSTALLED_QI' => '<strong>Installed by phpBB QuickInstall version %s</strong>',
180181
'LOREM_IPSUM' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',

modules/qi_settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class qi_settings
1919
{
2020
public function __construct()
2121
{
22-
global $settings, $template, $user, $quickinstall_path, $mode, $alt_env, $alt_env_missing;
22+
global $settings, $template, $user, $quickinstall_path, $phpbb_root_path, $mode, $alt_env, $alt_env_missing;
2323

2424
$saved = false;
2525
$config_text = '';
@@ -83,7 +83,7 @@ public function __construct()
8383
'ALT_ENV' => !empty($alt_env) ? $alt_env : false,
8484
'PROFILES' => $settings->get_profiles(),
8585
'QI_LANG' => qi::get_lang_select("{$quickinstall_path}language/", 'qi_lang', 'lang'),
86-
'PHPBB_LANG' => qi::get_lang_select("{$quickinstall_path}sources/phpBB3/language/", 'default_lang'),
86+
'PHPBB_LANG' => qi::get_lang_select("{$phpbb_root_path}/language/", 'default_lang'),
8787

8888
'CONFIG_TEXT' => htmlspecialchars($config_text),
8989

0 commit comments

Comments
 (0)