Skip to content

Commit

Permalink
Replace lambda function in Google translate plugin.
Browse files Browse the repository at this point in the history
Props GregRoss
See #305
Fixes #456
  • Loading branch information
markoheijnen committed Jul 17, 2015
1 parent b99f348 commit b08ad7b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/google-translate/google-translate.php
Expand Up @@ -205,10 +205,17 @@ public function google_translate_batch( $locale, $strings ) {
}

public function google_translate_fix( $string ) {
$string = preg_replace_callback( '/% (s|d)/i', lambda( '$m', '"%".strtolower($m[1])' ), $string );
$string = preg_replace_callback( '/% (\d+) \$ (s|d)/i', lambda( '$m', '"%".$m[1]."\\$".strtolower($m[2])' ), $string );
$string = preg_replace_callback( '/% (s|d)/i', function( $m ) {
return "%" . strtolower( $m[1] );
}, $string );

$string = preg_replace_callback( '/% (\d+) \$ (s|d)/i', function( $m ) {
return "%" . $m[1] . "\\$" . strtolower( $m[2] );
}, $string );

return $string;
}

}

GP::$plugins->gp_google_translate = new GP_Google_Translate;

0 comments on commit b08ad7b

Please sign in to comment.