From c0a32c8fb497a9accbd59b3a656df6eb21263bc2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 19 Apr 2010 09:34:50 +0000 Subject: [PATCH] Fix: Search if module directory name is different of lang file name we can use "langfile@mymodule" or "@mymodule" --- htdocs/core/translate.class.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/core/translate.class.php b/htdocs/core/translate.class.php index c63a306ef25..7a965d4354a 100644 --- a/htdocs/core/translate.class.php +++ b/htdocs/core/translate.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2009 Destailleur Laurent +/* Copyright (C) 2001 Eric Seigne + * Copyright (C) 2004-2010 Destailleur Laurent + * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ************************************************************************* */ + */ /** * \file htdocs/translate.class.php @@ -148,7 +148,18 @@ class Translate { //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); - $newdomain=str_replace('@','',$domain); // Remove the @ if present + $modulename = ''; + + // Search if module directory name is different of lang file name + if (preg_match('/^([^@]+)?@([^@]+)$/i',$domain,$regs)) + { + $newdomain = (!empty($regs[1])?$regs[1]:$regs[2]); + $modulename = (!empty($regs[1])?$regs[2]:''); + } + else + { + $newdomain=$domain; + } // Check cache if (! empty($this->tab_loaded[$newdomain])) // File already loaded for this domain @@ -170,7 +181,7 @@ class Translate { { // If $domain is @xxx instead of xxx then we look for module lang file htdocs/xxx/langs/code_CODE/xxx.lang // instead of global lang file htdocs/langs/code_CODE/xxx.lang - if (preg_match('/@/',$domain)) $searchdir=$searchdir ."/".$newdomain."/langs"; + if (preg_match('/@/',$domain)) $searchdir = $searchdir."/".(!empty($modulename)?$modulename:$newdomain)."/langs"; else $searchdir=$searchdir."/langs"; // Directory of translation files