30 $destinationFolder = $this->
getArg( 0 );
31 if ( !is_dir( $destinationFolder ) || !is_writable( $destinationFolder ) ) {
32 $errors[] =
"The path: $destinationFolder does not exist, is not a folder or is not writable.";
35 $messageFiles = $this->
getArgs( 1 );
36 foreach ( $messageFiles as $file ) {
37 if ( !file_exists( $file ) ) {
38 $errors[] =
"The message file: $file does not exist";
43 $this->
fatalError( implode(
"\n* ", $errors ) );
48 foreach ( $messageFiles as $file ) {
51 foreach ( LocalisationCache::ALL_ALIAS_KEYS as $key ) {
54 if ( isset( $$key ) ) {
63 foreach ( $data as $key => $item ) {
64 $normalizedKey = ucfirst( $key );
66 foreach ( $item as $languageCode => $itemData ) {
67 $json[$languageCode][$normalizedKey] = $itemData;
71 foreach ( $json as $languageCode => $data ) {
72 $filePath = $destinationFolder .
'/' . $languageCode .
".json";
75 FormatJson::encode( $data,
"\t", FormatJson::UTF8_OK ) .
"\n"
79 $this->
output(
"Done!\n" );