summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-10-30 04:54:38 +0100
committerGitHub <noreply@github.com>2019-10-30 04:54:38 +0100
commit4c81fee548a25acfa543b8fc95d9505204f9974b (patch)
tree5d1082d1d69e27ccad08243968ef2a6c7b7a6399 /src
parentd00d66a634498038de6d3536f434749070104b93 (diff)
parent8a298f0f5eedcf6520af58bdd3d5087b1fc39272 (diff)
Merge pull request #667 from lujoga/translation
Fix some translation-related issues
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)) {