Did you find any way to make this work?
Namespacing translations in Laravel with the same namespace (kinda prefix)
tl:dr:
Can two or more packages share the same namespace name? (in the following example package_lang)
FooPackage (ServiceProvider.php)
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'package_lang');
BarPackage (ServiceProvider.php)
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'package_lang');
BazPackage (ServiceProvider.php)
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'package_lang');
Instead of using a unique namespaces, like: foo_lang, bar_lang, baz_lang.
Btw, it works on the loadTranslationsFrom() method with the same namespace (like above, just resources/views directory), but not with loadTranslationsFrom().
Appreciate a little description why or why not?!
--- Detailed following below ---
In the ServiceProvider (of my packages) I always do
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'package_lang');
which literally resolves in foo_lang::, which is cool, because translations can be called like this package_lang::something.promoto
My custom packages does always follow the same structure. (ommited directories which aren't neccessary)
- Package Foo
- /resources
- /lang
- /en
- /foo
- /something.php
- /foo
- /es
- /foo
- /something.php
- /foo
- /en
- /views
- /lang
- /src
- PackageServiceProvider.php
- Package Bar
- /resources
- /lang
- /en
- /bar
- /something.php
- /bar
- /es
- /bar
- /something.php
- /bar
- /en
- /views
- /lang
- /src
- PackageServiceProvider.php
- Package Baz
- /resources
- /lang
- /en
- /baz
- /something.php
- /baz
- /es
- /baz
- /something.php
- /baz
- /en
- /views
- /lang
- /src
- PackageServiceProvider.php
It would be cool, if I can call my translation, which are from the same package-family (package_lang), with the namespace package_lang::foo.something.promote or package_lang::bar.something.promote
Please or to participate in this conversation.