Closed sardoj closed 5 years ago
@sardoj Hey! Thanks for the PR (and sorry for the late answer)! I really like the idea!
Please let me review the code and work on a little, then I will return to you!
Thanks a lot!
Thank you !
Maybe we can also add support for a fallback locale.
if (!is_null($dirpath)) {
if (strpos($dirpath, base_path()) === false) {
$dirpath = base_path($dirpath.'/'.App::getLocale());
// ===> If this locale is not supported by the package, it there will be no translations.
// Maybe we can use config('app.fallback_locale') if '$dirpath' doesn't exist.
}
} else {
$dirpath = resource_path('lang/'.App::getLocale());
}
@sardoj I really appreciate your idea!
I chose another approach since you can reach all the registered package translations with their path, there is no need to pass any extra parameter to the @translations directive, it can be done behind the scenes. Also, for the fallback locale, I used a similar approach, I just saw your comment after.
Also, for changing the separator, I think it's the best if we stick with the default separator. No confusion then.
So if you don't mind I close this PR, but in the readme and the changelog, where I document the package part, I will mention you in the very first.
Hello, Thank you for your new release! But i've a real problem with the separator, because I use dot character in my translations :
// resources/lang/en/default.php
return [
'test' => 'test1',
'field.test' => 'test2',
];
It works well with Laravel if we call trans('default.test')
or trans('default.field.test')
.
Could we do the same with your package please?
@sardoj Hi!
I see. But having a structure like this, would solve your problem, no? Or it's a bit more complicated than this?
// resources/lang/en/default.php
return [
'test' => 'test1',
'field' => ['test' => 'test2'],
];
@iamgergo You're true, it works well like this. Thank you!
It would be useful to use translation also with custom packages.
This pull request adds support for packages translation.