Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created December 30, 2013 21:31
Show Gist options
  • Save paulgibbs/8188490 to your computer and use it in GitHub Desktop.
Save paulgibbs/8188490 to your computer and use it in GitHub Desktop.
hack of WordPress' https://develop.svn.wordpress.org/trunk/tools/i18n/extract.php to find gettext strings without a textdomain
<?php
function extract_from_code( $code, $file_name ) {
$translations = new Translations;
$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
foreach( $function_calls as $call ) {
// These lines!
if ( in_array( 'buddypress', $call['args'] ) ) {
continue;
}
$entry = $this->entry_from_call( $call, $file_name );
if ( is_array( $entry ) )
foreach( $entry as $single_entry )
$translations->add_entry_or_merge( $single_entry );
elseif ( $entry)
$translations->add_entry_or_merge( $entry );
}
return $translations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment