mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
cleanup around lc code; add to JNI
This commit is contained in:
parent
4190926c0a
commit
33b636b458
5 changed files with 38 additions and 19 deletions
|
@ -200,8 +200,6 @@ public class DictsDelegate extends ListDelegateBase
|
|||
LangInfo info = (LangInfo)dataObj;
|
||||
int groupPos = info.m_posn;
|
||||
String langName = m_langs[groupPos];
|
||||
int langCode = DictLangCache.getLangLangCode( m_context,
|
||||
langName );
|
||||
boolean expanded = ! m_closedLangs.contains( langName );
|
||||
String locLangName = xlateLang( langName );
|
||||
String details = null;
|
||||
|
|
|
@ -276,6 +276,7 @@ public class XwJNI {
|
|||
|
||||
public static native CommsAddrRec comms_getInitialAddr();
|
||||
public static native String comms_getUUID();
|
||||
public static native String lcToLocale( int lc );
|
||||
|
||||
// Game methods
|
||||
private static GamePtr initGameJNI( long rowid )
|
||||
|
|
|
@ -987,6 +987,20 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getUUID
|
|||
return jstr;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_lcToLocale
|
||||
( JNIEnv* env, jclass C, jint lc )
|
||||
{
|
||||
jstring result = NULL;
|
||||
const XP_UCHAR* locale = lcToLocale( lc );
|
||||
if ( !!locale ) {
|
||||
result = (*env)->NewStringUTF( env, locale );
|
||||
} else {
|
||||
XP_LOGFF( "(%d) => NULL", lc );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1make
|
||||
( JNIEnv* env, jclass C, jlong jniGlobalPtr, jbyteArray jDictBytes,
|
||||
|
|
|
@ -363,8 +363,13 @@ parseCommon( DictionaryCtxt* dctx, XWEnv xwe, const XP_U8** ptrp, const XP_U8* e
|
|||
const XP_UCHAR* isoCode = lcToLocale( dctx->langCode );
|
||||
XP_ASSERT( !!isoCode );
|
||||
dctx->isoCode = copyString( dctx->mpool, isoCode );
|
||||
XP_LOGFF( "looked up isoCode %s for langCode %d", isoCode, dctx->langCode );
|
||||
XP_LOGFF( "looked up isoCode %s for langCode %d", isoCode,
|
||||
dctx->langCode );
|
||||
}
|
||||
#ifdef DEBUG
|
||||
const XP_UCHAR* locale = lcToLocale( dctx->langCode );
|
||||
XP_ASSERT( !locale || !XP_STRCMP( locale, dctx->isoCode ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( formatOk ) {
|
||||
|
|
|
@ -422,21 +422,20 @@ lcToLocale( XP_LangCode lc )
|
|||
{
|
||||
const XP_UCHAR* result = NULL;
|
||||
switch ( lc ) {
|
||||
case 0: result = "??"; break;
|
||||
case 1: result = "en"; break;
|
||||
case 2: result = "fr"; break;
|
||||
case 3: result = "de"; break;
|
||||
case 4: result = "tr"; break;
|
||||
case 5: result = "ar"; break;
|
||||
case 6: result = "es"; break;
|
||||
case 7: result = "sv"; break;
|
||||
case 8: result = "pl"; break;
|
||||
case 9: result = "da"; break;
|
||||
case 0xA: result = "it"; break;
|
||||
case 0xB: result = "nl"; break;
|
||||
case 0xC: result = "ca"; break;
|
||||
case 0xD: result = "pt"; break;
|
||||
case 0xF: result = "ru"; break;
|
||||
case 0x01: result = "en"; break;
|
||||
case 0x02: result = "fr"; break;
|
||||
case 0x03: result = "de"; break;
|
||||
case 0x04: result = "tr"; break;
|
||||
case 0x05: result = "ar"; break;
|
||||
case 0x06: result = "es"; break;
|
||||
case 0x07: result = "sv"; break;
|
||||
case 0x08: result = "pl"; break;
|
||||
case 0x09: result = "da"; break;
|
||||
case 0x0A: result = "it"; break;
|
||||
case 0x0B: result = "nl"; break;
|
||||
case 0x0C: result = "ca"; break;
|
||||
case 0x0D: result = "pt"; break;
|
||||
case 0x0F: result = "ru"; break;
|
||||
case 0x11: result = "cs"; break;
|
||||
case 0x12: result = "el"; break;
|
||||
case 0x13: result = "sk"; break;
|
||||
|
@ -444,7 +443,9 @@ lcToLocale( XP_LangCode lc )
|
|||
case 0x15: result = "ro"; break;
|
||||
case 0x19: result = "fi"; break;
|
||||
}
|
||||
XP_ASSERT( !!result );
|
||||
if ( !result ) {
|
||||
XP_LOGFF( "(%d/0x%x) => NULL", lc, lc );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue