aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2015-08-23 22:42:18 +0200
committerTristan Darricau <tristan.darricau@sensiolabs.com>2015-08-23 22:42:18 +0200
commitf6a4843c6df3a9b0490eb3d273ebed7d04a89582 (patch)
treeb031ba516adf54d5d3764528e696651b02ceef92 /phpBB/phpbb
parentf56fe0ba8da2211d3947369e79952f294cffe7d6 (diff)
parent25103698040977fd0d655d6e658157a07bb24990 (diff)
downloadforums-f6a4843c6df3a9b0490eb3d273ebed7d04a89582.tar
forums-f6a4843c6df3a9b0490eb3d273ebed7d04a89582.tar.gz
forums-f6a4843c6df3a9b0490eb3d273ebed7d04a89582.tar.bz2
forums-f6a4843c6df3a9b0490eb3d273ebed7d04a89582.tar.xz
forums-f6a4843c6df3a9b0490eb3d273ebed7d04a89582.zip
Merge pull request #3652 from Elsensee/ticket/12143
[ticket/12143] Make it possible to use translated group names for non-special groups * Elsensee/ticket/12143: [ticket/12143] Fix tests after rebase [ticket/12143] Avoid no output from get_group_name() [ticket/12143] Fix those tests [ticket/12143] Add some tests [ticket/12143] Oops, fixed array index [ticket/12143] Replace group name output [ticket/12143] Add group helper class to translate groupnames [ticket/12143] Add is_set method to language service
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/group/helper.php40
-rw-r--r--phpBB/phpbb/language/language.php30
2 files changed, 70 insertions, 0 deletions
diff --git a/phpBB/phpbb/group/helper.php b/phpBB/phpbb/group/helper.php
new file mode 100644
index 0000000000..5befddfc53
--- /dev/null
+++ b/phpBB/phpbb/group/helper.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\group;
+
+class helper
+{
+ /** @var \phpbb\language\language */
+ protected $language;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\language\language $language Language object
+ */
+ public function __construct(\phpbb\language\language $language)
+ {
+ $this->language = $language;
+ }
+
+ /**
+ * @param $group_name string The stored group name
+ *
+ * @return string Group name or translated group name if it exists
+ */
+ public function get_name($group_name)
+ {
+ return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name;
+ }
+}
diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php
index 44131e3da3..3ffb466c19 100644
--- a/phpBB/phpbb/language/language.php
+++ b/phpBB/phpbb/language/language.php
@@ -194,6 +194,36 @@ class language
}
/**
+ * @param $key array|string The language key we want to know more about. Can be string or array.
+ *
+ * @return bool Returns whether the language key is set.
+ */
+ public function is_set($key)
+ {
+ // Load common language files if they not loaded yet
+ if (!$this->common_language_files_loaded)
+ {
+ $this->load_common_language_files();
+ }
+
+ if (is_array($key))
+ {
+ $lang = &$this->lang[array_shift($key)];
+
+ foreach ($key as $_key)
+ {
+ $lang = &$lang[$_key];
+ }
+ }
+ else
+ {
+ $lang = &$this->lang[$key];
+ }
+
+ return isset($lang);
+ }
+
+ /**
* Advanced language substitution
*
* Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms.