get translations working in dicts browser (save title)

This commit is contained in:
Eric House 2014-04-14 08:05:11 -07:00
parent 67ca205774
commit 7f48783fb2
2 changed files with 30 additions and 18 deletions

View file

@ -248,8 +248,8 @@ public class DictsDelegate extends DelegateBase
case MOVE_DICT:
final XWListItem[] selItems = getSelItems();
final int[] moveTo = { -1 };
message = m_activity.getString( R.string.move_dict_fmt,
getJoinedNames( selItems ) );
message = LocUtils.getString( m_activity, R.string.move_dict_fmt,
getJoinedNames( selItems ) );
OnClickListener newSelLstnr =
new OnClickListener() {
@ -310,8 +310,9 @@ public class DictsDelegate extends DelegateBase
};
String name = row.getText();
String lang = DictLangCache.getLangName( m_activity, name);
message = m_activity.getString( R.string.set_default_message_fmt,
name, lang );
message = LocUtils.getString( m_activity,
R.string.set_default_message_fmt,
name, lang );
dialog = new LocUtils.AlertBuilder( m_activity )
.setTitle( R.string.query_title )
.setMessage( message )
@ -378,12 +379,11 @@ public class DictsDelegate extends DelegateBase
}
}
Resources res = m_activity.getResources();
m_locNames = res.getStringArray( R.array.loc_names );
m_locNames = LocUtils.getStringArray( m_activity, R.array.loc_names );
m_downloadStr = m_activity.getString( R.string.download_dicts );
m_downloadStr = LocUtils.getString( m_activity, R.string.download_dicts );
m_activity.setContentView( R.layout.dict_browse );
setContentView( R.layout.dict_browse );
m_expView = m_activity.getExpandableListView();
m_expView.setOnItemLongClickListener( this );
@ -504,7 +504,7 @@ public class DictsDelegate extends DelegateBase
SharedPreferences sp
= PreferenceManager.getDefaultSharedPreferences( m_activity );
SharedPreferences.Editor editor = sp.edit();
String key = m_activity.getString( keyId );
String key = LocUtils.getString( m_activity, keyId );
String name = view.getText();
editor.putString( key, name );
editor.commit();
@ -538,8 +538,9 @@ public class DictsDelegate extends DelegateBase
private void deleteSelected()
{
XWListItem[] items = getSelItems();
String msg = m_activity.getString( R.string.confirm_delete_dict_fmt,
getJoinedNames( items ) );
String msg = LocUtils.getString( m_activity,
R.string.confirm_delete_dict_fmt,
getJoinedNames( items ) );
// When and what to warn about. First off, if there's another
// identical dict, simply confirm. Or if nobody's using this
@ -563,12 +564,14 @@ public class DictsDelegate extends DelegateBase
if ( 1 == langDals.length ) { // last in this language?
if ( 0 < nUsingLang ) {
newMsg =
m_activity.getString( R.string.confirm_deleteonly_dict_fmt,
dict, langName );
LocUtils.getString( m_activity, R.string
.confirm_deleteonly_dict_fmt,
dict, langName );
}
} else if ( 0 < DBUtils.countGamesUsingDict( m_activity, dict ) ) {
newMsg = m_activity.getString( R.string.confirm_deletemore_dict_fmt,
langName );
newMsg = LocUtils.getString( m_activity, R.string.
confirm_deletemore_dict_fmt,
langName );
}
if ( null != newMsg ) {
msg += "\n\n" + newMsg;
@ -717,8 +720,9 @@ public class DictsDelegate extends DelegateBase
{
int nSels = m_selDicts.size();
if ( 0 < nSels ) {
m_activity.setTitle( LocUtils.getString( m_activity, R.string.sel_items_fmt,
nSels ) );
m_activity.setTitle( LocUtils.getString( m_activity,
R.string.sel_items_fmt,
nSels ) );
} else {
m_activity.setTitle( m_origTitle );
}

View file

@ -23,6 +23,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
@ -31,9 +32,9 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.Iterator;
import java.util.HashMap;
@ -121,6 +122,13 @@ public class LocUtils {
return result;
}
public static String[] getStringArray( Context context, int resID )
{
Resources res = context.getResources();
String[] arr = res.getStringArray( resID );
return xlateStrings( context, arr );
}
public static String[] xlateStrings( Context context, String[] strs )
{
String[] result = new String[strs.length];