Skip to content

Commit

Permalink
support translating array attributes for php array translations
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmuhittin committed May 23, 2019
1 parent e676118 commit d611a32
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/commands/TranslateFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ public function translate_php_array_files($locale)
}
continue;
}
$new_lang[$key] = self::translate($this->base_locale, $locale, $to_be_translated);
if ($this->verbose) {
$this->line($to_be_translated . ' : ' . $new_lang[$key]);
}
$new_lang[$key] = $this->translate_attribute($to_be_translated,$locale);
}
}
//save new lang to new file
Expand All @@ -246,6 +243,22 @@ public function translate_php_array_files($locale)
return;
}

private function translate_attribute($attribute,$locale){
if(is_array($attribute)){
$return = [];
foreach ($attribute as $k => $t){
$return[$k] = $this->translate_attribute($t,$locale);
}
return $return;
}else{
$translated = self::translate($this->base_locale, $locale, $attribute);
if ($this->verbose) {
$this->line($attribute . ' : ' . $translated);
}
return $translated;
}
}

/**
* @return array
*/
Expand Down

0 comments on commit d611a32

Please sign in to comment.