Merge pull request from ArthurHoaro/feature/theme-translation

Load theme translations files automatically
This commit is contained in:
ArthurHoaro 2018-03-26 20:26:10 +02:00 committed by GitHub
commit 9b2bd66fb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 98 additions and 2 deletions
tests
LanguagesTest.php
languages/fr
utils/customtpl/dummy/language/fr/LC_MESSAGES

View file

@ -175,6 +175,32 @@ class LanguagesTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($text, t($text));
}
/**
* Test t() with an extension language file coming from the theme in gettext mode
*/
public function testTranslationThemeExtensionGettext()
{
$this->conf->set('translation.mode', 'gettext');
$this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
$this->conf->set('theme', 'dummy');
new Languages('en', $this->conf);
$txt = 'rooster'; // ignore me poedit
$this->assertEquals('rooster', t($txt, $txt, 1, 'dummy'));
}
/**
* Test t() with an extension language file coming from the theme in PHP mode
*/
public function testTranslationThemeExtensionPhp()
{
$this->conf->set('translation.mode', 'php');
$this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
$this->conf->set('theme', 'dummy');
new Languages('en', $this->conf);
$txt = 'rooster'; // ignore me poedit
$this->assertEquals('rooster', t($txt, $txt, 1, 'dummy'));
}
/**
* Test t() with an extension language file in gettext mode
*/

View file

@ -172,4 +172,30 @@ class LanguagesFrTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('voiture', t($txt, $txt, 1, 'test'));
$this->assertEquals('Fouille', t('Search', 'Search', 1, 'test'));
}
/**
* Test t() with an extension language file coming from the theme in gettext mode
*/
public function testTranslationThemeExtensionGettext()
{
$this->conf->set('translation.mode', 'gettext');
$this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
$this->conf->set('theme', 'dummy');
new Languages('en', $this->conf);
$txt = 'rooster'; // ignore me poedit
$this->assertEquals('coq', t($txt, $txt, 1, 'dummy'));
}
/**
* Test t() with an extension language file coming from the theme in PHP mode
*/
public function testTranslationThemeExtensionPhp()
{
$this->conf->set('translation.mode', 'php');
$this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
$this->conf->set('theme', 'dummy');
new Languages('en', $this->conf);
$txt = 'rooster'; // ignore me poedit
$this->assertEquals('coq', t($txt, $txt, 1, 'dummy'));
}
}

View file

@ -0,0 +1,16 @@
msgid ""
msgstr ""
"Project-Id-Version: Theme extension test\n"
"POT-Creation-Date: 2017-05-20 13:54+0200\n"
"PO-Revision-Date: 2018-03-26 19:09+0200\n"
"Last-Translator: \n"
"Language-Team: Shaarli\n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 2.0.6\n"
msgid "rooster"
msgstr "coq"