31 $destinationFolder = $this->
getArg( 0 );
32 if ( !is_dir( $destinationFolder ) || !is_writable( $destinationFolder ) ) {
33 $errors[] =
"The path: $destinationFolder does not exist, is not a folder or is not writable.";
36 $messageFiles = $this->
getArgs( 1 );
37 foreach ( $messageFiles as $file ) {
38 if ( !file_exists( $file ) ) {
39 $errors[] =
"The message file: $file does not exist";
44 $this->
fatalError( implode(
"\n* ", $errors ) );
49 foreach ( $messageFiles as $file ) {
52 foreach ( LocalisationCache::ALL_ALIAS_KEYS as $key ) {
55 if ( isset( $$key ) ) {
64 foreach ( $data as $key => $item ) {
65 $normalizedKey = ucfirst( $key );
67 foreach ( $item as $languageCode => $itemData ) {
68 $json[$languageCode][$normalizedKey] = $itemData;
72 foreach ( $json as $languageCode => $data ) {
73 $filePath = $destinationFolder .
'/' . $languageCode .
".json";
76 FormatJson::encode( $data,
"\t", FormatJson::UTF8_OK ) .
"\n"
80 $this->
output(
"Done!\n" );