From: Janusz Dobrowolski Date: Mon, 8 Nov 2010 10:50:05 +0000 (+0000) Subject: Fixed support for translations in extensions modules reports. X-Git-Tag: v2.4.2~19^2~505 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c2e4edb8bd1eb60893f042f562bf2b817f06fd81;p=fa-stable.git Fixed support for translations in extensions modules reports. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7d249ca5..192556c3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +08-Nov-2010 Janusz Dobrowolski +# Fixed support for report translations in extension modules +$ /includes/main.inc + /reporting/includes/class.pdf.inc + 07-Nov-2010 Janusz Dobrowolski ! Separate class for view and print/email links (also fixes conflict with confirmation dialog) $ /includes/ui/ui_controls.inc diff --git a/includes/main.inc b/includes/main.inc index 17037409..ee756478 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -302,19 +302,21 @@ function copy_file($file, $from, $to) /* Search for file, looking first for company specific version, then for version provided by any extension module, finally in main FA directory. - Also adds include path for any related files. + Also adds include path for any related files, and sets $local_path_to_root + to enable local translation domains. Returns found file path or null. */ function find_custom_file($rep) { - global $installed_extensions, $path_to_root; + global $installed_extensions, $path_to_root, $local_path_to_root; // customized per company version $path = company_path(); $file = $path.$rep; if (file_exists($file)) { // add local include path + $local_path_to_root = $path; set_include_path(dirname($file).PATH_SEPARATOR.get_include_path()); return $file; } @@ -324,6 +326,7 @@ function find_custom_file($rep) $extensions = $installed_extensions; foreach ($extensions as $ext) if (($ext['active'] && $ext['type'] == 'extension')) { + $local_path_to_root = $path = $path_to_root.'/'.$ext['path']; $file = $path.$rep; if (file_exists($file)) { diff --git a/reporting/includes/class.pdf.inc b/reporting/includes/class.pdf.inc index 7b5ee8d2..0bf38d8f 100644 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@ -79,15 +79,21 @@ class Cpdf extends FPDI { */ function SetLang($code=null) { - global $installed_languages, $dflt_lang, $path_to_root; + global $installed_languages, $dflt_lang, $path_to_root, $local_path_to_root; if (!$code) $code = $dflt_lang; $lang = array_search_value($code, $installed_languages, 'code'); $_SESSION['get_text']->set_language($lang['code'], strtoupper($lang['encoding'])); - $_SESSION['get_text']->add_domain($lang['code'], $path_to_root . "/lang", @$lang['version']); + // $local_path_to_root is set inside find_custom_file. + // Select extension domain if po file is provided + // otherwise use global translation. + if (file_exists($local_path_to_root.'/lang/'.$lang['code'].'/LC_MESSAGES/'.$lang['code'].'.po')) + $_SESSION['get_text']->add_domain($lang['code'], $local_path_to_root . "/lang"); + else + $_SESSION['get_text']->add_domain($lang['code'], $path_to_root . "/lang", @$lang['version']); // re-read translated sys names. include($path_to_root.'/includes/sysnames.inc');