Merge pull request #667 from lujoga/translation
Fix some translation-related issues
This commit is contained in:
commit
4c81fee548
|
@ -0,0 +1,36 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Engelsystem 2.0\n"
|
||||||
|
"Language-Team: \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"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language: de_DE\n"
|
||||||
|
|
||||||
|
msgid "auth.not-found"
|
||||||
|
msgstr ""
|
||||||
|
"Es wurde kein User gefunden oder das Passwort ist falsch. Probiere es bitte noch einmal. Wenn das Problem "
|
||||||
|
"weiterhin besteht, melde dich im Himmel."
|
||||||
|
|
||||||
|
msgid "validation.password.required"
|
||||||
|
msgstr "Bitte gib ein Passwort an."
|
||||||
|
|
||||||
|
msgid "validation.login.required"
|
||||||
|
msgstr "Bitte gib einen Loginnamen an."
|
||||||
|
|
||||||
|
msgid "validation.email.required"
|
||||||
|
msgstr "Bitte gib eine E-Mail-Adresse an."
|
||||||
|
|
||||||
|
msgid "validation.email.email"
|
||||||
|
msgstr "Die E-Mail-Adresse ist nicht gültig."
|
||||||
|
|
||||||
|
msgid "validation.password.min"
|
||||||
|
msgstr "Dein angegebenes Passwort ist zu kurz."
|
||||||
|
|
||||||
|
msgid "validation.password.confirmed"
|
||||||
|
msgstr "Deine Passwörter stimmen nicht überein."
|
||||||
|
|
||||||
|
msgid "validation.password_confirmation.required"
|
||||||
|
msgstr "Du musst dein Passwort bestätigen."
|
|
@ -10,8 +10,8 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"X-Generator: Poedit 1.8.11\n"
|
"X-Generator: Poedit 1.8.11\n"
|
||||||
"X-Poedit-KeywordsList: __;_e;translate;translatePlural\n"
|
"X-Poedit-KeywordsList: __;_e:1,2;translate;translatePlural\n"
|
||||||
"X-Poedit-Basepath: ../../../..\n"
|
"X-Poedit-Basepath: ../../..\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
"X-Poedit-SourceCharset: UTF-8\n"
|
"X-Poedit-SourceCharset: UTF-8\n"
|
||||||
"X-Poedit-SearchPath-0: resources/views\n"
|
"X-Poedit-SearchPath-0: resources/views\n"
|
||||||
|
@ -1535,12 +1535,6 @@ msgstr "Pflichtfeld!"
|
||||||
#~ msgid "auth.no-password"
|
#~ msgid "auth.no-password"
|
||||||
#~ msgstr "Gib bitte ein Passwort ein."
|
#~ msgstr "Gib bitte ein Passwort ein."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:418
|
|
||||||
msgid "auth.not-found"
|
|
||||||
msgstr ""
|
|
||||||
"Es wurde kein User gefunden oder das Passwort ist falsch. Probiere es bitte noch einmal. Wenn das Problem "
|
|
||||||
"weiterhin besteht, melde dich im Himmel."
|
|
||||||
|
|
||||||
#~ msgid "auth.no-nickname"
|
#~ msgid "auth.no-nickname"
|
||||||
#~ msgstr "Gib bitte einen Nick an."
|
#~ msgstr "Gib bitte einen Nick an."
|
||||||
|
|
||||||
|
@ -2767,26 +2761,21 @@ msgstr ""
|
||||||
"Diese Seite existiert nicht oder Du hast keinen Zugriff. Melde Dich an um "
|
"Diese Seite existiert nicht oder Du hast keinen Zugriff. Melde Dich an um "
|
||||||
"Zugriff zu erhalten!"
|
"Zugriff zu erhalten!"
|
||||||
|
|
||||||
msgid "validation.password.required"
|
|
||||||
msgstr "Bitte gib ein Passwort an."
|
|
||||||
|
|
||||||
msgid "validation.login.required"
|
|
||||||
msgstr "Bitte gib einen Loginnamen an."
|
|
||||||
|
|
||||||
msgid "form.submit"
|
msgid "form.submit"
|
||||||
msgstr "Absenden"
|
msgstr "Absenden"
|
||||||
|
|
||||||
msgid "validation.email.required"
|
msgid "credits.credit"
|
||||||
msgstr "Bitte gib eine E-Mail-Adresse an."
|
msgstr ""
|
||||||
|
"Das ursprüngliche Engelsystem wurde entwickelt von "
|
||||||
|
"[cookie](https://github.com/cookieBerlin/engelsystem)"
|
||||||
|
". Danach wurde es von "
|
||||||
|
"[msquare](https://notrademark.de)"
|
||||||
|
" (Maintainer) und "
|
||||||
|
"[MyIgel](https://myigel.name)"
|
||||||
|
" völlig überarbeitet und verbessert."
|
||||||
|
|
||||||
msgid "validation.email.email"
|
msgid "credits.contributors"
|
||||||
msgstr "Die E-Mail-Adresse ist nicht gültig."
|
msgstr ""
|
||||||
|
"Eine vollständige Liste der Mitwirkenden findest Du "
|
||||||
msgid "validation.password.min"
|
"[auf GitHub](https://github.com/engelsystem/engelsystem/graphs/contributors)"
|
||||||
msgstr "Dein angegebenes Passwort ist zu kurz."
|
"."
|
||||||
|
|
||||||
msgid "validation.password.confirmed"
|
|
||||||
msgstr "Deine Passwörter stimmen nicht überein."
|
|
||||||
|
|
||||||
msgid "validation.password_confirmation.required"
|
|
||||||
msgstr "Du musst dein Passwort bestätigen."
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Engelsystem 2.0\n"
|
||||||
|
"Language-Team: \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"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language: en_US\n"
|
||||||
|
|
||||||
|
msgid "auth.not-found"
|
||||||
|
msgstr "No user was found or password is wrong. Please try again. If you are still having problems, ask Heaven."
|
||||||
|
|
||||||
|
msgid "validation.password.required"
|
||||||
|
msgstr "The password is required."
|
||||||
|
|
||||||
|
msgid "validation.login.required"
|
||||||
|
msgstr "The login name is required."
|
||||||
|
|
||||||
|
msgid "validation.email.required"
|
||||||
|
msgstr "The email address is required."
|
||||||
|
|
||||||
|
msgid "validation.email.email"
|
||||||
|
msgstr "This email address is not valid."
|
||||||
|
|
||||||
|
msgid "validation.password.min"
|
||||||
|
msgstr "Your password is too short."
|
||||||
|
|
||||||
|
msgid "validation.password.confirmed"
|
||||||
|
msgstr "Your passwords are not equal."
|
||||||
|
|
||||||
|
msgid "validation.password_confirmation.required"
|
||||||
|
msgstr "You have to confirm your password."
|
|
@ -22,29 +22,21 @@ msgstr ""
|
||||||
#~ msgid "auth.no-password"
|
#~ msgid "auth.no-password"
|
||||||
#~ msgstr "Please enter a password."
|
#~ msgstr "Please enter a password."
|
||||||
|
|
||||||
msgid "auth.not-found"
|
|
||||||
msgstr "No user was found or password is wrong. Please try again. If you are still having problems, ask Heaven."
|
|
||||||
|
|
||||||
msgid "validation.password.required"
|
|
||||||
msgstr "The password is required."
|
|
||||||
|
|
||||||
msgid "validation.login.required"
|
|
||||||
msgstr "The login name is required."
|
|
||||||
|
|
||||||
msgid "form.submit"
|
msgid "form.submit"
|
||||||
msgstr "Submit"
|
msgstr "Submit"
|
||||||
|
|
||||||
msgid "validation.email.required"
|
msgid "credits.credit"
|
||||||
msgstr "The email address is required."
|
msgstr ""
|
||||||
|
"The original engelsystem was written by "
|
||||||
|
"[cookie](https://github.com/cookieBerlin/engelsystem)"
|
||||||
|
". It was then completely rewritten and enhanced by "
|
||||||
|
"[msquare](https://notrademark.de)"
|
||||||
|
" (maintainer) and "
|
||||||
|
"[MyIgel](https://myigel.name)"
|
||||||
|
"."
|
||||||
|
|
||||||
msgid "validation.email.email"
|
msgid "credits.contributors"
|
||||||
msgstr "This email address is not valid."
|
msgstr ""
|
||||||
|
"Please have a look at the "
|
||||||
msgid "validation.password.min"
|
"[contributors list on GitHub](https://github.com/engelsystem/engelsystem/graphs/contributors)"
|
||||||
msgstr "Your password is too short."
|
" for a complete list."
|
||||||
|
|
||||||
msgid "validation.password.confirmed"
|
|
||||||
msgstr "Your passwords are not equal."
|
|
||||||
|
|
||||||
msgid "validation.password_confirmation.required"
|
|
||||||
msgstr "You have to confirm your password."
|
|
||||||
|
|
|
@ -17,15 +17,10 @@
|
||||||
<h2>{{ __('Source code') }}</h2>
|
<h2>{{ __('Source code') }}</h2>
|
||||||
<p>{{ __('Version: _%s_', [version])|markdown }}</i></p>
|
<p>{{ __('Version: _%s_', [version])|markdown }}</i></p>
|
||||||
<p>
|
<p>
|
||||||
{{ __('The original engelsystem was written by
|
{{ __('credits.credit')|markdown }}
|
||||||
[cookie](https://github.com/cookieBerlin/engelsystem).
|
|
||||||
It was then completely rewritten and enhanced by [msquare](https://notrademark.de) (maintainer) and
|
|
||||||
[MyIgel](https://myigel.name).')|markdown }}
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{{ __('Please have a look at the
|
{{ __('credits.contributors')|markdown }}
|
||||||
[contributors list on GitHub](https://github.com/engelsystem/engelsystem/graphs/contributors)
|
|
||||||
for a complete list.')|markdown }}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -70,17 +70,20 @@ class TranslationServiceProvider extends ServiceProvider
|
||||||
public function getTranslator(string $locale): GettextTranslator
|
public function getTranslator(string $locale): GettextTranslator
|
||||||
{
|
{
|
||||||
if (!isset($this->translators[$locale])) {
|
if (!isset($this->translators[$locale])) {
|
||||||
$file = $this->getFile($locale);
|
$names = ['default', 'additional'];
|
||||||
|
|
||||||
/** @var GettextTranslator $translator */
|
/** @var GettextTranslator $translator */
|
||||||
$translator = $this->app->make(GettextTranslator::class);
|
$translator = $this->app->make(GettextTranslator::class);
|
||||||
|
|
||||||
/** @var Translations $translations */
|
/** @var Translations $translations */
|
||||||
$translations = $this->app->make(Translations::class);
|
$translations = $this->app->make(Translations::class);
|
||||||
if (Str::endsWith($file, '.mo')) {
|
foreach ($names as $name) {
|
||||||
$translations->addFromMoFile($file);
|
$file = $this->getFile($locale, $name);
|
||||||
} else {
|
if (Str::endsWith($file, '.mo')) {
|
||||||
$translations->addFromPoFile($file);
|
$translations->addFromMoFile($file);
|
||||||
|
} else {
|
||||||
|
$translations->addFromPoFile($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$translator->loadTranslations($translations);
|
$translator->loadTranslations($translations);
|
||||||
|
@ -93,11 +96,12 @@ class TranslationServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getFile(string $locale): string
|
protected function getFile(string $locale, string $name = 'default'): string
|
||||||
{
|
{
|
||||||
$filepath = $file = $this->app->get('path.lang') . '/' . $locale . '/default';
|
$filepath = $file = $this->app->get('path.lang') . '/' . $locale . '/' . $name;
|
||||||
$file = $filepath . '.mo';
|
$file = $filepath . '.mo';
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Testing content
|
||||||
|
msgid "validation.foo.bar"
|
||||||
|
msgstr "B Arr required!"
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
# Testing content
|
||||||
|
msgid "validation.foo.bar"
|
||||||
|
msgstr "Foo Bar required!"
|
|
@ -7,6 +7,7 @@ use Engelsystem\Helpers\Translation\TranslationServiceProvider;
|
||||||
use Engelsystem\Helpers\Translation\Translator;
|
use Engelsystem\Helpers\Translation\Translator;
|
||||||
use Engelsystem\Test\Unit\ServiceProviderTest;
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
|
||||||
class TranslationServiceProviderTest extends ServiceProviderTest
|
class TranslationServiceProviderTest extends ServiceProviderTest
|
||||||
|
@ -82,11 +83,12 @@ class TranslationServiceProviderTest extends ServiceProviderTest
|
||||||
$app = $this->getApp(['get']);
|
$app = $this->getApp(['get']);
|
||||||
$serviceProvider = new TranslationServiceProvider($app);
|
$serviceProvider = new TranslationServiceProvider($app);
|
||||||
|
|
||||||
$this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets');
|
$this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets', new InvokedCount(2));
|
||||||
|
|
||||||
// Get translator
|
// Get translator
|
||||||
$translator = $serviceProvider->getTranslator('fo_OO');
|
$translator = $serviceProvider->getTranslator('fo_OO');
|
||||||
$this->assertEquals('Foo Bar!', $translator->gettext('foo.bar'));
|
$this->assertEquals('Foo Bar!', $translator->gettext('foo.bar'));
|
||||||
|
$this->assertEquals('Foo Bar required!', $translator->gettext('validation.foo.bar'));
|
||||||
|
|
||||||
// Retry from cache
|
// Retry from cache
|
||||||
$serviceProvider->getTranslator('fo_OO');
|
$serviceProvider->getTranslator('fo_OO');
|
||||||
|
@ -99,12 +101,13 @@ class TranslationServiceProviderTest extends ServiceProviderTest
|
||||||
public function testGetTranslatorFromPo(): void
|
public function testGetTranslatorFromPo(): void
|
||||||
{
|
{
|
||||||
$app = $this->getApp(['get']);
|
$app = $this->getApp(['get']);
|
||||||
$this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets');
|
$this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets', new InvokedCount(2));
|
||||||
|
|
||||||
$serviceProvider = new TranslationServiceProvider($app);
|
$serviceProvider = new TranslationServiceProvider($app);
|
||||||
|
|
||||||
// Get translator using a .po file
|
// Get translator using a .po file
|
||||||
$translator = $serviceProvider->getTranslator('ba_RR');
|
$translator = $serviceProvider->getTranslator('ba_RR');
|
||||||
$this->assertEquals('B Arr!', $translator->gettext('foo.bar'));
|
$this->assertEquals('B Arr!', $translator->gettext('foo.bar'));
|
||||||
|
$this->assertEquals('B Arr required!', $translator->gettext('validation.foo.bar'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue