mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
translate language names downloaded as part of dict info.
This commit is contained in:
parent
16e3ef9246
commit
3b53d05746
2 changed files with 49 additions and 16 deletions
|
@ -64,10 +64,11 @@ import java.util.Iterator;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
|
||||
import org.eehouse.android.xw4.jni.GameSummary;
|
||||
import org.eehouse.android.xw4.DictUtils.DictLoc;
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
import org.eehouse.android.xw4.jni.GameSummary;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
public class DictsDelegate extends ListDelegateBase
|
||||
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
|
||||
|
@ -108,16 +109,17 @@ public class DictsDelegate extends ListDelegateBase
|
|||
|
||||
private static class DictInfo implements Comparable {
|
||||
public String m_name;
|
||||
// public boolean m_needsUpdate;
|
||||
public String m_lang;
|
||||
public String m_langLoc;
|
||||
public int m_nWords;
|
||||
public long m_nBytes;
|
||||
public String m_note;
|
||||
public DictInfo( String name, String lang, int nWords, long nBytes,
|
||||
String note )
|
||||
public DictInfo( String name, String lang, String langLoc, int nWords,
|
||||
long nBytes, String note )
|
||||
{
|
||||
m_name = name;
|
||||
m_lang = lang;
|
||||
m_langLoc = langLoc;
|
||||
m_nWords = nWords;
|
||||
m_nBytes = nBytes;
|
||||
m_note = note;
|
||||
|
@ -136,7 +138,6 @@ public class DictsDelegate extends ListDelegateBase
|
|||
m_numDicts = numDicts;
|
||||
}
|
||||
}
|
||||
private HashMap<String, DictAndLoc[]> m_localInfo;
|
||||
private HashMap<String, DictInfo[]> m_remoteInfo;
|
||||
|
||||
private boolean m_launchedForMissing = false;
|
||||
|
@ -1174,14 +1175,15 @@ public class DictsDelegate extends ListDelegateBase
|
|||
for ( int ii = 0; !isCancelled() && ii < nLangs; ++ii ) {
|
||||
JSONObject langObj = langs.getJSONObject( ii );
|
||||
String langName = langObj.getString( "lang" );
|
||||
String locLangName = LocUtils.xlateLang( m_context, langName );
|
||||
|
||||
if ( null != m_filterLang &&
|
||||
! m_filterLang.equals( langName ) ) {
|
||||
! m_filterLang.equals( locLangName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! curLangs.contains( langName ) ) {
|
||||
closedLangs.add( langName );
|
||||
if ( ! curLangs.contains( locLangName ) ) {
|
||||
closedLangs.add( locLangName );
|
||||
}
|
||||
|
||||
JSONArray dicts = langObj.getJSONArray( "dicts" );
|
||||
|
@ -1200,13 +1202,13 @@ public class DictsDelegate extends ListDelegateBase
|
|||
note = null;
|
||||
}
|
||||
DictInfo info =
|
||||
new DictInfo( name, langName, nWords, nBytes,
|
||||
note );
|
||||
new DictInfo( name, langName, locLangName,
|
||||
nWords, nBytes, note );
|
||||
|
||||
if ( !m_quickFetchMode ) {
|
||||
// Check if we have it and it needs an update
|
||||
if ( DictLangCache.haveDict( m_activity,
|
||||
langName, name )){
|
||||
locLangName, name )){
|
||||
boolean matches = true;
|
||||
String curSum = DictLangCache
|
||||
.getDictMD5Sum( m_activity, name );
|
||||
|
@ -1237,7 +1239,7 @@ public class DictsDelegate extends ListDelegateBase
|
|||
DictInfo[] asArray = new DictInfo[dictNames.size()];
|
||||
asArray = dictNames.toArray( asArray );
|
||||
Arrays.sort( asArray );
|
||||
m_remoteInfo.put( langName, asArray );
|
||||
m_remoteInfo.put( locLangName, asArray );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1253,7 @@ public class DictsDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
} // digestData
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// DialogInterface.OnCancelListener interface
|
||||
|
|
|
@ -80,10 +80,11 @@ public class LocUtils {
|
|||
private static Boolean s_enabled = null;
|
||||
private static String s_curLocale;
|
||||
private static WeakReference<Menu> s_latestMenuRef;
|
||||
private static HashMap<WeakReference<Menu>, HashSet<String> > s_menuSets
|
||||
private static Map<WeakReference<Menu>, HashSet<String> > s_menuSets
|
||||
= new HashMap<WeakReference<Menu>, HashSet<String> >();
|
||||
private static HashMap<String, HashSet<String> > s_contextSets
|
||||
private static Map<String, HashSet<String> > s_contextSets
|
||||
= new HashMap<String, HashSet<String> >();
|
||||
private static Map<String, String> s_langMap = null;
|
||||
|
||||
public static void localeChanged( Context context, String newLocale )
|
||||
{
|
||||
|
@ -111,6 +112,36 @@ public class LocUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String xlateLang( Context context, String lang )
|
||||
{
|
||||
if ( null == s_langMap ) {
|
||||
s_langMap = new HashMap<String, String>();
|
||||
s_langMap.put( "English", context.getString( R.string.lang_name_english ) );
|
||||
s_langMap.put( "French", context.getString( R.string.lang_name_french ) );
|
||||
s_langMap.put( "German", context.getString( R.string.lang_name_german ) );
|
||||
s_langMap.put( "Turkish", context.getString( R.string.lang_name_turkish ) );
|
||||
s_langMap.put( "Arabic", context.getString( R.string.lang_name_arabic ) );
|
||||
s_langMap.put( "Spanish", context.getString( R.string.lang_name_spanish ) );
|
||||
s_langMap.put( "Swedish", context.getString( R.string.lang_name_swedish ) );
|
||||
s_langMap.put( "Polish", context.getString( R.string.lang_name_polish ) );
|
||||
s_langMap.put( "Danish", context.getString( R.string.lang_name_danish ) );
|
||||
s_langMap.put( "Italian", context.getString( R.string.lang_name_italian ) );
|
||||
s_langMap.put( "Dutch", context.getString( R.string.lang_name_dutch ) );
|
||||
s_langMap.put( "Catalan", context.getString( R.string.lang_name_catalan ) );
|
||||
s_langMap.put( "Portuguese", context.getString( R.string.lang_name_portuguese ) );
|
||||
s_langMap.put( "Russian", context.getString( R.string.lang_name_russian ) );
|
||||
s_langMap.put( "Czech", context.getString( R.string.lang_name_czech ) );
|
||||
s_langMap.put( "Greek", context.getString( R.string.lang_name_greek ) );
|
||||
s_langMap.put( "Slovak", context.getString( R.string.lang_name_slovak ) );
|
||||
}
|
||||
|
||||
String xlated = s_langMap.get( lang );
|
||||
if ( null == xlated ) {
|
||||
xlated = lang;
|
||||
}
|
||||
return xlated;
|
||||
}
|
||||
|
||||
public static void xlateView( Activity activity )
|
||||
{
|
||||
xlateView( activity, Utils.getContentView( activity ) );
|
||||
|
|
Loading…
Reference in a new issue