1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Helpers/Language/NinjaTranslator.php
2020-08-11 11:33:43 +10:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Helpers\Language;
use Illuminate\Support\Arr;
use Illuminate\Translation\Translator;
class NinjaTranslator extends Translator
{
/**
* Set translation.
*
* @param string $key
* @param mixed $value
* @param string $locale
* @return void
*/
public function set($key, $value, $locale = null)
{
list($namespace, $group, $item) = $this->parseKey($key);
if(null === $locale)
$locale = $this->locale;
// Load given group defaults if exists
$this->load($namespace, $group, $locale);
Arr::set($this->loaded[$namespace][$group][$locale], $item, $value);
}
public function replace($items, $locale = null)
{
if(null === $locale)
$locale = $this->locale;
foreach($items as $key => $value)
{
list($namespace, $group, $item) = $this->parseKey($key);
$this->load($namespace, $group, $locale);
Arr::set($this->loaded[$namespace][$group][$locale], $item, $value);
}
}
}