Browse Source

#687 Label for attribute Person:name always shown in english (Last Name)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2632 a333f486-631f-4898-b8df-5754b55c2be0
romainq 12 năm trước cách đây
mục cha
commit
41ad54817d
2 tập tin đã thay đổi với 21 bổ sung18 xóa
  1. 5 5
      core/attributedef.class.inc.php
  2. 16 13
      core/dict.class.inc.php

+ 5 - 5
core/attributedef.class.inc.php

@@ -220,7 +220,7 @@ abstract class AttributeDefinition
 			$sDefault = str_replace('_', ' ', $this->m_sCode);
 		}
 
-		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode, '');
+		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode, '', true /* user language only */);
 		if (strlen($sLabel) == 0)
 		{
 			// Nothing found: go higher in the hierarchy (if possible)
@@ -277,7 +277,7 @@ abstract class AttributeDefinition
 		{
 			$sDefault = '';
 		}
-		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'+', '');
+		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'+', '', true /* user language only */);
 		if (strlen($sLabel) == 0)
 		{
 			// Nothing found: go higher in the hierarchy (if possible)
@@ -303,7 +303,7 @@ abstract class AttributeDefinition
 		{
 			$sDefault = '';
 		}
-		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'?', '');
+		$sLabel = Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'?', '', true /* user language only */);
 		if (strlen($sLabel) == 0)
 		{
 			// Nothing found: go higher in the hierarchy (if possible)
@@ -2224,7 +2224,7 @@ class AttributeEnum extends AttributeString
 		}
 		else
 		{
-			$sLabel = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue, '');
+			$sLabel = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue, '', true /* user language only */);
 			if (strlen($sLabel) == 0)
 			{
 				$sLabel = str_replace('_', ' ', $sValue);
@@ -2251,7 +2251,7 @@ class AttributeEnum extends AttributeString
 		}
 		else
 		{
-			$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+', '');
+			$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+', '', true /* user language only */);
 			if (strlen($sDescription) == 0)
 			{
 				$sParentClass = MetaModel::GetParentClass($this->m_sHostClass);

+ 16 - 13
core/dict.class.inc.php

@@ -120,7 +120,7 @@ class Dict
 	}
 
 
-	public static function S($sStringCode, $sDefault = null)
+	public static function S($sStringCode, $sDefault = null, $bUserLanguageOnly = false)
 	{
 		// Attempt to find the string in the user language
 		//
@@ -134,19 +134,22 @@ class Dict
 		{
 			return $aCurrentDictionary[$sStringCode];
 		}
-		// Attempt to find the string in the default language
-		//
-		$aDefaultDictionary = self::$m_aData[self::$m_sDefaultLanguage];
-		if (array_key_exists($sStringCode, $aDefaultDictionary))
+		if (!$bUserLanguageOnly)
 		{
-			return $aDefaultDictionary[$sStringCode];
-		}
-		// Attempt to find the string in english
-		//
-		$aDefaultDictionary = self::$m_aData['EN US'];
-		if (array_key_exists($sStringCode, $aDefaultDictionary))
-		{
-			return $aDefaultDictionary[$sStringCode];
+			// Attempt to find the string in the default language
+			//
+			$aDefaultDictionary = self::$m_aData[self::$m_sDefaultLanguage];
+			if (array_key_exists($sStringCode, $aDefaultDictionary))
+			{
+				return $aDefaultDictionary[$sStringCode];
+			}
+			// Attempt to find the string in english
+			//
+			$aDefaultDictionary = self::$m_aData['EN US'];
+			if (array_key_exists($sStringCode, $aDefaultDictionary))
+			{
+				return $aDefaultDictionary[$sStringCode];
+			}
 		}
 		// Could not find the string...
 		//