Skip to content

Commit

Permalink
Package names will now be added to appropriate language and not as ke…
Browse files Browse the repository at this point in the history
…ys directly in messages
  • Loading branch information
kg-bot committed Jun 8, 2018
1 parent a30b86c commit 1e5d960
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/Classes/ExportLocalizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ function dirToArray( $dir )

if ( $lang === 'vendor' ) {

$package_langs = [];
foreach ( $file as $package => $langs ) {

$package_lang = [];

foreach ( $langs as $lang => $messages ) {

$package_messages = [];
foreach ( $messages as $message ) {

Expand All @@ -59,14 +55,18 @@ function dirToArray( $dir )
require $file_path;
}

$package_lang[ $lang ] = $package_messages;
// Here we need for each package language to find if we already have that language in string, if
// we do then join package messages to it, if not create new
if ( in_array( $lang, array_keys( $strings ) ) ) {

}
$strings[ $lang ][ $package ] = $package_messages;

$package_langs[ $package ] = $package_lang;
}
} else {

$strings = array_merge( $strings, $package_langs );
$strings[ $lang ] = [ $package => $package_messages ];
}
}
}

} else {

Expand All @@ -77,10 +77,16 @@ function dirToArray( $dir )

$langs[ ( explode( '.php', basename( $file_path ) ) )[ 0 ] ] = require $file_path;
}
$languages[ $lang ] = $langs;
}

$strings = array_merge( $strings, $languages );
if ( in_array( $lang, array_keys( $strings ) ) ) {

array_merge( $strings[ $lang ], $langs );

} else {

$strings[ $lang ] = $langs;
}
}
}

event( new LaravelLocalizationExported( $strings ) );
Expand Down

0 comments on commit 1e5d960

Please sign in to comment.