? hook_potx.diff Index: potx.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/potx/Attic/potx.inc,v retrieving revision 1.1.2.17.2.7.2.14 diff -u -p -r1.1.2.17.2.7.2.14 potx.inc --- potx.inc 26 Sep 2008 10:44:32 -0000 1.1.2.17.2.7.2.14 +++ potx.inc 5 Oct 2008 17:24:12 -0000 @@ -131,6 +131,11 @@ function _potx_process_file($file_path, _potx_find_info_file_strings($file_path, $file_name, $save_callback, $api_version); return; } + // The .potx files return return custom strings. + elseif ($name_parts['extension'] == 'potx') { + _potx_find_potx_file_strings($file_path, $file_name, $save_callback); + return; + } elseif ($name_parts['extension'] == 'js' && $api_version > POTX_API_5) { _potx_parse_js_file($code, $file_name, $save_callback); } @@ -1074,6 +1079,29 @@ function _potx_find_info_file_strings($f } /** + * Call method in a .potx file and add relevant strings to the list. + * + * @param $file_path + * Complete file path to load contents with. + * @param $file_name + * Stripped file name to use in outpout. + * @param $save_callback + * Function to call to save individual strings. + */ +function _potx_find_potx_file_strings($file_path, $file_name, $save_callback) { + include_once($file_path); + // Can't use module_invoke() because the module may not be enabled. + $module = basename($file_path, '.potx'); + $function = $module . '_pots'; + if (function_exists($function)) { + $strings = call_user_func($function); + foreach ($strings as $string) { + $save_callback($string, $file_name); + } + } +} + +/** * Parse a JavaScript file for translatables. Only for Drupal 6. * * Extracts strings wrapped in Drupal.t() and Drupal.formatPlural() @@ -1147,7 +1175,7 @@ function _potx_parse_js_string($string) function _potx_explore_dir($path = '', $basename = '*', $api_version = POTX_API_6) { // It would be so nice to just use GLOB_BRACE, but it is not available on all // operarting systems, so we are working around the missing functionality. - $extensions = array('php', 'inc', 'module', 'engine', 'theme', 'install', 'info', 'profile'); + $extensions = array('php', 'inc', 'module', 'engine', 'theme', 'install', 'info', 'profile', 'potx'); if ($api_version > POTX_API_5) { $extensions[] = 'js'; }