1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-18 22:41:28 +02:00

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
This commit is contained in:
Tristan Darricau
2015-08-23 22:42:18 +02:00
22 changed files with 286 additions and 68 deletions

View File

@@ -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;
}
}

View File

@@ -193,6 +193,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
*