summaryrefslogtreecommitdiff
path: root/tests/units/Core/TranslatorTest.php
blob: 6aa480e121b8d71994a7d42add9a32cdb8998836 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

require_once __DIR__.'/../Base.php';

use Kanboard\Core\Translator;

class TranslatorTest extends Base
{
    public function setUp()
    {
        parent::setUp();
        Translator::unload();
    }

    public function testLoading()
    {
        $translator = new Translator();
        $this->assertSame('Yes', $translator->translate('Yes'));

        Translator::load('fr_FR');
        $this->assertSame('Oui', $translator->translate('Yes'));

        Translator::unload();
        $this->assertSame('Yes', $translator->translate('Yes'));

        Translator::load('de_DE', Translator::getDefaultFolder());
        $this->assertSame('Ja', $translator->translate('Yes'));
    }

    public function testNumberFormatting()
    {
        $translator = new Translator();
        $this->assertSame('1,024.42', $translator->number(1024.42));

        Translator::load('fr_FR');
        $this->assertSame('1 024,42', $translator->number(1024.42));
    }

    public function testTranslateEscaping()
    {
        $translator = new Translator();
        $this->assertSame('&lt;b&gt;', $translator->translate('<b>'));
        $this->assertSame('<b>', $translator->translateNoEscaping('<b>'));
    }
}