summaryrefslogtreecommitdiffstats
path: root/vendor/gipfl/icingaweb2/src/Translator.php
blob: b1cb08872938697566ae3aaf8fef2c7e4b5c107f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace gipfl\IcingaWeb2;

use gipfl\Translation\TranslatorInterface;

class Translator implements TranslatorInterface
{
    /** @var string */
    private $domain;

    public function __construct($domain)
    {
        $this->domain = $domain;
    }

    public function translate($string)
    {
        $res = dgettext($this->domain, $string);
        if ($res === $string && $this->domain !== 'icinga') {
            return dgettext('icinga', $string);
        }

        return $res;
    }
}