mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
get rid of allcaps translation, instead using translations where
available. Works -- but app needs to be restarted for menus to change.
This commit is contained in:
parent
a351b2a5b9
commit
2ae6ecb125
1 changed files with 33 additions and 6 deletions
|
@ -41,6 +41,7 @@ public class LocUtils {
|
||||||
// files to mark me-localized strings.
|
// files to mark me-localized strings.
|
||||||
private static final String LOC_PREFIX = "loc:";
|
private static final String LOC_PREFIX = "loc:";
|
||||||
private static HashMap<String, String>s_xlations = null;
|
private static HashMap<String, String>s_xlations = null;
|
||||||
|
private static HashMap<Integer, String> s_idsToKeys = null;
|
||||||
|
|
||||||
public interface LocIface {
|
public interface LocIface {
|
||||||
void setText( CharSequence text );
|
void setText( CharSequence text );
|
||||||
|
@ -92,16 +93,25 @@ public class LocUtils {
|
||||||
|
|
||||||
public static String getString( Context context, int id )
|
public static String getString( Context context, int id )
|
||||||
{
|
{
|
||||||
String str = context.getString( id );
|
return getString( context, id, (Object)null );
|
||||||
str = str.toUpperCase();
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString( Context context, int id, Object... params )
|
public static String getString( Context context, int id, Object... params )
|
||||||
{
|
{
|
||||||
String str = context.getString( id );
|
String result = null;
|
||||||
str = String.format( str, params );
|
String key = keyForID( id );
|
||||||
return str.toUpperCase();
|
if ( null != key ) {
|
||||||
|
result = getXlation( context, key );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( null == result ) {
|
||||||
|
result = context.getString( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( null != result && null != params ) {
|
||||||
|
result = String.format( result, params );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setXlation( Context context, String key, String txt )
|
public static void setXlation( Context context, String key, String txt )
|
||||||
|
@ -189,4 +199,21 @@ public class LocUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String keyForID( int id )
|
||||||
|
{
|
||||||
|
if ( null == s_idsToKeys ) {
|
||||||
|
HashMap<String,Integer> map = LocIDsData.s_map;
|
||||||
|
HashMap<Integer, String> idsToKeys =
|
||||||
|
new HashMap<Integer, String>( map.size() );
|
||||||
|
|
||||||
|
Iterator<String> iter = map.keySet().iterator();
|
||||||
|
while ( iter.hasNext() ) {
|
||||||
|
String key = iter.next();
|
||||||
|
idsToKeys.put( map.get( key ), key );
|
||||||
|
}
|
||||||
|
s_idsToKeys = idsToKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_idsToKeys.get( id );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue