Fixed support for translations in extensions modules reports.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 8 Nov 2010 10:50:05 +0000 (10:50 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 8 Nov 2010 10:50:05 +0000 (10:50 +0000)
CHANGELOG.txt
includes/main.inc
reporting/includes/class.pdf.inc

index 7d249ca5e61e21020f96c7307e12db0d7d35edfd..192556c3c3a055224542f919801a69d50111bfae 100644 (file)
@@ -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
index 170374090c22db04573f5ec844d04c3b3800cbd3..ee7564785f0d8d020ad50668938d9279799a22c5 100644 (file)
@@ -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)) {
index 7b5ee8d2f6637d06154023ba21448b5854278dff..0bf38d8f1756f9d0dc7532e6b76540d734a16a6a 100644 (file)
@@ -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');