diff options
author | Oliver Schramm <oliver.schramm97@gmail.com> | 2015-04-07 18:59:11 +0200 |
---|---|---|
committer | Oliver Schramm <oliver.schramm97@gmail.com> | 2016-08-21 05:21:25 +0200 |
commit | eccb3d66025b4d10c40135b29ad36cc763a08571 (patch) | |
tree | 96ee4990707a8d7f1eaac052b1b549a35511eee4 | |
parent | 488fd8f54c1ef7f1703942477d014ac071e5cc56 (diff) | |
download | forums-eccb3d66025b4d10c40135b29ad36cc763a08571.tar forums-eccb3d66025b4d10c40135b29ad36cc763a08571.tar.gz forums-eccb3d66025b4d10c40135b29ad36cc763a08571.tar.bz2 forums-eccb3d66025b4d10c40135b29ad36cc763a08571.tar.xz forums-eccb3d66025b4d10c40135b29ad36cc763a08571.zip |
[ticket/13709] Add fallback for email templates used by extensions
Also add a fallback to english for the core
like we do it in $user->add_lang()
PHPBB3-13709
-rw-r--r-- | phpBB/includes/functions_messenger.php | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 0525cfc29e..9b3ca14101 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -231,6 +231,13 @@ class messenger $template_lang = basename($config['default_lang']); } + $ext_template_paths = array( + array( + 'name' => $template_lang . '_email', + 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix, + ), + ); + if ($template_path) { $template_paths = array( @@ -246,23 +253,38 @@ class messenger $template_path . $template_dir_prefix, ); + $board_language = basename($config['default_lang']); + // we can only specify default language fallback when the path is not a custom one for which we // do not know the default language alternative - if ($template_lang !== basename($config['default_lang'])) + if ($template_lang !== $board_language) { $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $fallback_template_path .= basename($config['default_lang']) . '/email'; + $fallback_template_path .= $board_language . '/email'; $template_paths[] = $fallback_template_path . $template_dir_prefix; + + $ext_template_paths[] = array( + 'name' => $board_language . '_email', + 'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix, + ); + } + // If everything fails just fall back to en template + if ($template_lang !== 'en' && $board_language !== 'en') + { + $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; + $fallback_template_path .= 'en/email'; + + $template_paths[] = $fallback_template_path . $template_dir_prefix; + + $ext_template_paths[] = array( + 'name' => 'en_email', + 'ext_path' => 'language/en/email' . $template_dir_prefix, + ); } } - $this->set_template_paths(array( - array( - 'name' => $template_lang . '_email', - 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix, - ), - ), $template_paths); + $this->set_template_paths($ext_template_paths, $template_paths); $this->template->set_filenames(array( 'body' => $template_file . '.txt', |