Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON localization files not working from laravel package #19980

Closed
ahmeddabak opened this issue Jul 10, 2017 · 1 comment
Closed

JSON localization files not working from laravel package #19980

ahmeddabak opened this issue Jul 10, 2017 · 1 comment

Comments

@ahmeddabak
Copy link
Contributor

  • Laravel Version: 5.4.2
  • PHP Version: 7.0.10

Description:

inside my package service provider in the boot method i have loaded my translation files

$this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'ideenkonzept');

and when i try to echo a translation {{ __('ideenkonzept::URL') }} it does not work

sine the namespace is not being extracted from the key and passed to the file Translator->Fileloader

i managed to get it to work by hard coding my namespace in the Fileloader which is wrong todo

/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php
 public function load($locale, $group, $namespace = null)
    {
        if ($group == '*' && $namespace == '*') {
            // before editing return $this->loadJsonPath($this->path, $locale);
            // the translation file array is saved in $this->hints[namespace]
            // but the name space is not passed to the loader and the loader
            // always return default translation path
            return $this->loadJsonPath($this->hints['ideenkonzept'], $locale);
        }

        if (is_null($namespace) || $namespace == '*') {
            return $this->loadPath($this->path, $locale, $group);
        }

        return $this->loadNamespaced($locale, $group, $namespace);
    }
@themsaid
Copy link
Member

Duplicate of #17923

@themsaid themsaid marked this as a duplicate of #17923 Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants