[2856097] The "Enter new Location/Address" countries are not translate - refactor to avoid static variable

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2856097
This commit is contained in:
Carlos Ruiz 2010-05-05 03:47:30 +00:00
parent d66b21d397
commit 4a702f8cca
3 changed files with 17 additions and 6 deletions

View File

@ -28,6 +28,7 @@ import java.util.logging.Level;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language; import org.compiere.util.Language;
/** /**
@ -139,9 +140,21 @@ public final class MCountry extends X_C_Country
+ " - Default=" + s_default); + " - Default=" + s_default);
} // loadAllCountries } // loadAllCountries
/**
* Return Language
* @return Name
*/
private String getEnvLanguage() {
String lang = Env.getAD_Language(Env.getCtx());
if (Language.isBaseLanguage(lang))
return null;
return lang;
}
/** /**
* Set the Language for Display (toString) * Set the Language for Display (toString)
* @param AD_Language language or null * @param AD_Language language or null
* @deprecated - not used at all, you can delete references to this method
*/ */
public static void setDisplayLanguage (String AD_Language) public static void setDisplayLanguage (String AD_Language)
{ {
@ -204,7 +217,7 @@ public final class MCountry extends X_C_Country
*/ */
public String toString() public String toString()
{ {
if (s_AD_Language != null) if (getEnvLanguage() != null)
{ {
String nn = getTrlName(); String nn = getTrlName();
if (nn != null) if (nn != null)
@ -219,11 +232,11 @@ public final class MCountry extends X_C_Country
*/ */
public String getTrlName() public String getTrlName()
{ {
if (m_trlName == null && s_AD_Language != null) if (m_trlName == null && getEnvLanguage() != null)
{ {
m_trlName = get_Translation(COLUMNNAME_Name, s_AD_Language); m_trlName = get_Translation(COLUMNNAME_Name, getEnvLanguage());
if (m_trlName == null) if (m_trlName == null)
s_AD_Language = null; // assume that there is no translation m_trlName = getName();
} }
return m_trlName; return m_trlName;
} // getTrlName } // getTrlName

View File

@ -113,7 +113,6 @@ public class VLocationDialog extends CDialog
Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null); Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null);
// Current Country // Current Country
MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
fCountry = new CComboBox(MCountry.getCountries(Env.getCtx())); fCountry = new CComboBox(MCountry.getCountries(Env.getCtx()));
fCountry.setSelectedItem(m_location.getCountry()); fCountry.setSelectedItem(m_location.getCountry());
m_origCountry_ID = m_location.getC_Country_ID(); m_origCountry_ID = m_location.getC_Country_ID();

View File

@ -131,7 +131,6 @@ public class WLocationDialog extends Window implements EventListener
initComponents(); initComponents();
init(); init();
// Current Country // Current Country
MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
for (MCountry country:MCountry.getCountries(Env.getCtx())) for (MCountry country:MCountry.getCountries(Env.getCtx()))
{ {
lstCountry.appendItem(country.toString(), country); lstCountry.appendItem(country.toString(), country);