[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.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language;
/**
@ -139,9 +140,21 @@ public final class MCountry extends X_C_Country
+ " - Default=" + s_default);
} // 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)
* @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)
{
@ -204,7 +217,7 @@ public final class MCountry extends X_C_Country
*/
public String toString()
{
if (s_AD_Language != null)
if (getEnvLanguage() != null)
{
String nn = getTrlName();
if (nn != null)
@ -219,11 +232,11 @@ public final class MCountry extends X_C_Country
*/
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)
s_AD_Language = null; // assume that there is no translation
m_trlName = getName();
}
return m_trlName;
} // 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);
// Current Country
MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
fCountry = new CComboBox(MCountry.getCountries(Env.getCtx()));
fCountry.setSelectedItem(m_location.getCountry());
m_origCountry_ID = m_location.getC_Country_ID();

View File

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