Skip to content

Commit 1e5d960

Browse files
committed
Package names will now be added to appropriate language and not as keys directly in messages
1 parent a30b86c commit 1e5d960

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/Classes/ExportLocalizations.php

+18-12
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ function dirToArray( $dir )
4343

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

46-
$package_langs = [];
4746
foreach ( $file as $package => $langs ) {
4847

49-
$package_lang = [];
50-
5148
foreach ( $langs as $lang => $messages ) {
52-
5349
$package_messages = [];
5450
foreach ( $messages as $message ) {
5551

@@ -59,14 +55,18 @@ function dirToArray( $dir )
5955
require $file_path;
6056
}
6157

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

64-
}
62+
$strings[ $lang ][ $package ] = $package_messages;
6563

66-
$package_langs[ $package ] = $package_lang;
67-
}
64+
} else {
6865

69-
$strings = array_merge( $strings, $package_langs );
66+
$strings[ $lang ] = [ $package => $package_messages ];
67+
}
68+
}
69+
}
7070

7171
} else {
7272

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

7878
$langs[ ( explode( '.php', basename( $file_path ) ) )[ 0 ] ] = require $file_path;
7979
}
80-
$languages[ $lang ] = $langs;
81-
}
8280

83-
$strings = array_merge( $strings, $languages );
81+
if ( in_array( $lang, array_keys( $strings ) ) ) {
82+
83+
array_merge( $strings[ $lang ], $langs );
84+
85+
} else {
86+
87+
$strings[ $lang ] = $langs;
88+
}
89+
}
8490
}
8591

8692
event( new LaravelLocalizationExported( $strings ) );

0 commit comments

Comments
 (0)