Merge pull request #1093 from ArthurHoaro/feature/theme-translation
Load theme translations files automatically
This commit is contained in:
commit
9b2bd66fb6
6 changed files with 98 additions and 2 deletions
tests
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
BIN
tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo
Normal file
BIN
tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo
Normal file
Binary file not shown.
16
tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po
Normal file
16
tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po
Normal 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"
|
Loading…
Add table
Add a link
Reference in a new issue