translations come in with ids rather than English strings as keys

This commit is contained in:
Eric House 2014-04-24 06:31:27 -07:00
parent 8612a5f624
commit 28c0862604

View file

@ -55,8 +55,6 @@ import org.eehouse.android.xw4.Utils;
import org.eehouse.android.xw4.XWPrefs; import org.eehouse.android.xw4.XWPrefs;
public class LocUtils { public class LocUtils {
// Keep this in sync with gen_loc_ids.py and what's used in the menu.xml
// files to mark me-localized strings.
private static final int FMT_LEN = 4; private static final int FMT_LEN = 4;
private static final String k_LOCALE = "locale"; private static final String k_LOCALE = "locale";
private static final String k_XLATPROTO = "proto"; private static final String k_XLATPROTO = "proto";
@ -262,7 +260,9 @@ public class LocUtils {
Map<String,String> newXlations = new HashMap<String,String>( len ); Map<String,String> newXlations = new HashMap<String,String>( len );
for ( int ii = 0; ii < len; ++ii ) { for ( int ii = 0; ii < len; ++ii ) {
JSONObject pair = pairs.getJSONObject( ii ); JSONObject pair = pairs.getJSONObject( ii );
String key = pair.getString( "en" ); int id = pair.getInt( "id" );
String key = context.getString( id );
Assert.assertNotNull( key );
String txt = pair.getString( "loc" ); String txt = pair.getString( "loc" );
newXlations.put( key, txt ); newXlations.put( key, txt );
} }
@ -420,18 +420,22 @@ public class LocUtils {
// formatters. // formatters.
private static String toUpperCase( String str ) private static String toUpperCase( String str )
{ {
String[] parts = str.split( "%[\\d]\\$[ds]" ); String result = null;
StringBuilder sb = new StringBuilder(); if ( UPPER_CASE ) {
int offset = 0; String[] parts = str.split( "%[\\d]\\$[ds]" );
for ( String part : parts ) { StringBuilder sb = new StringBuilder();
sb.append( part.toUpperCase() ); int offset = 0;
offset += part.length(); for ( String part : parts ) {
if ( offset < str.length() ) { sb.append( part.toUpperCase() );
sb.append( str.substring( offset, offset + FMT_LEN ) ); offset += part.length();
offset += FMT_LEN; if ( offset < str.length() ) {
sb.append( str.substring( offset, offset + FMT_LEN ) );
offset += FMT_LEN;
}
} }
result = sb.toString();
} }
return sb.toString(); return result;
} }
public static AlertDialog.Builder makeAlertBuilder( Context context ) public static AlertDialog.Builder makeAlertBuilder( Context context )