Ticket #860 (closed defect: fixed)

Opened 5 months ago

Last modified 4 months ago

Prado::localize() bug

Reported by: japplegame Owned by: xue
Priority: low Milestone: 3.1.3
Component: Prado Framework v3 Version: 3.1
Severity: minor Keywords:
Cc:

Description

Prado version 3.1.2 Prado::localize() ignores current value of Application.Globalization.TranslationCatalogue property For example: Content of Index.page

<%@ Application.Globalization.TranslationCatalogue="mycat"%>
<com:TTranslation Text="Sample text"/><br/>
<%[Sample text]%>

TTranslate gets translated text from "mycat" catalogue. That's right. Prado::localize ignores <%@ Application.Globalization.TranslationCatalogue?="mycat"%> directive and gets translated text from default catalogue "messages".

I have changed PradoBase.php and bug has gone. But i am not shure that it is right solution. Diff:

Index: framework/PradoBase.php
===================================================================
--- framework/PradoBase.php	(revision 2463)
+++ framework/PradoBase.php	(working copy)
@@ -572,11 +572,11 @@
 		if($app===null || ($config = $app->getTranslationConfiguration())===null)
 			return strtr($text, $params);
 
-		Translation::init();
-
 		if(empty($catalogue) && isset($config['catalogue']))
 			$catalogue = $config['catalogue'];
 
+		Translation::init($catalogue);
+
 		//globalization charset
 		$appCharset = $app===null ? '' : $app->getCharset();
 
@@ -587,7 +587,7 @@
 		if(empty($charset)) $charset = $appCharset;
 		if(empty($charset)) $charset = $defaultCharset;
 
-		return Translation::formatter()->format($text,$params,$catalogue,$charset);
+		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
 	}
 }

Change History

Changed 4 months ago by japplegame

There is mistake. Default catalogue (messages) works incorrectly after applaying diff. This is corrected diff:

Index: framework/PradoBase.php
===================================================================
--- framework/PradoBase.php	(revision 2463)
+++ framework/PradoBase.php	(working copy)
@@ -572,10 +572,13 @@
 		if($app===null || ($config = $app->getTranslationConfiguration())===null)
 			return strtr($text, $params);
 
-		Translation::init();
+		if(is_null($catalogue))
+		{
+			if(isset($config['catalogue'])) $catalogue = $config['catalogue'];
+			else $catalogue = 'messages';
+		}
 
-		if(empty($catalogue) && isset($config['catalogue']))
-			$catalogue = $config['catalogue'];
+		Translation::init($catalogue);
 
 		//globalization charset
 		$appCharset = $app===null ? '' : $app->getCharset();
@@ -587,7 +590,7 @@
 		if(empty($charset)) $charset = $appCharset;
 		if(empty($charset)) $charset = $defaultCharset;
 
-		return Translation::formatter()->format($text,$params,$catalogue,$charset);
+		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
 	}
 }
 

Changed 4 months ago by tof06

  • milestone set to 3.1.3

Changed 4 months ago by tof06

  • status changed from new to closed
  • resolution set to fixed

Thanks !

Note: See TracTickets for help on using tickets.