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

added support for packages loadTranslationsFrom method #149

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

MeRoBo
Copy link

@MeRoBo MeRoBo commented Aug 25, 2020

added support for packages which register language files via loadTranslationsFrom with override ability from local language vendor folder

…sanlationsFrom with override ability from local language vendor folder

$fullPath = $file->getRealPath();
if ($extension == 'php') {
$messages[$key] = array_replace(Arr::get($messages,$key,[]), include $fullPath);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to check the include $fullPath actually returns a filled array before adding it.

You can add a test for it for trying to include a translation file, that isn't a valid translation file.

{
$pathName = $file->getRelativePathName();
$extension = $file->getExtension();
if ($extension != 'php' && $extension != 'json') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change it to for readability
$supportedExtensions = ['json', 'php'];
!in_array($extension, $supportedExtensions)

I'm thinking laravel actually does this already somehow, maybe we should look into
The Illuminate\Translation\Translator uses Illuminate\Translation\FileLoaderto load/process files. Maybe we can use some of that logic

@StefanPrintezis
Copy link

Seems like this ain't appyling to 1.7.0 for laravel 8 anymore

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

Successfully merging this pull request may close these issues.

None yet

2 participants