summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca <Luca@hackerspace-bamberg.de>2019-10-25 09:33:09 +0200
committerLuca <Luca@hackerspace-bamberg.de>2019-10-28 14:25:31 +0100
commit6cde313e47cd08216ff15d733c8de894f2657a8b (patch)
tree21158b5c4ba3b84307f5c946d5dcffa20cd828f1 /src
parentd10fe2336671905c8529095c896031a56dbe1b29 (diff)
Move translations whose message ids do not appear as literals in the sources into a separate file
Test whether additional.{m,p}o files are loaded correctly
Diffstat (limited to 'src')
-rw-r--r--src/Helpers/Translation/TranslationServiceProvider.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Helpers/Translation/TranslationServiceProvider.php b/src/Helpers/Translation/TranslationServiceProvider.php
index 6df9b0fe..5534a1c3 100644
--- a/src/Helpers/Translation/TranslationServiceProvider.php
+++ b/src/Helpers/Translation/TranslationServiceProvider.php
@@ -70,17 +70,20 @@ class TranslationServiceProvider extends ServiceProvider
public function getTranslator(string $locale): GettextTranslator
{
if (!isset($this->translators[$locale])) {
- $file = $this->getFile($locale);
+ $names = ['default', 'additional'];
/** @var GettextTranslator $translator */
$translator = $this->app->make(GettextTranslator::class);
/** @var Translations $translations */
$translations = $this->app->make(Translations::class);
- if (Str::endsWith($file, '.mo')) {
- $translations->addFromMoFile($file);
- } else {
- $translations->addFromPoFile($file);
+ foreach ($names as $name) {
+ $file = $this->getFile($locale, $name);
+ if (Str::endsWith($file, '.mo')) {
+ $translations->addFromMoFile($file);
+ } else {
+ $translations->addFromPoFile($file);
+ }
}
$translator->loadTranslations($translations);
@@ -93,11 +96,12 @@ class TranslationServiceProvider extends ServiceProvider
/**
* @param string $locale
+ * @param string $name
* @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';
if (!file_exists($file)) {