// Path: src/com/hughes/android/dictionary/DictionaryInfo.java
// public static final class IndexInfo implements Serializable {
//     private static final long serialVersionUID = 6524751236198309438L;
// 
//     static final int NUM_CSV_FIELDS = 3;
// 
//     public final String shortName; // Often LangISO.
//     final int allTokenCount;
//     public final int mainTokenCount;
// 
//     public IndexInfo(String shortName, int allTokenCount, int mainTokenCount) {
//         this.shortName = shortName;
//         this.allTokenCount = allTokenCount;
//         this.mainTokenCount = mainTokenCount;
//     }
// 
//     void append(StringBuilder result) {
//         result.append(shortName);
//         result.append("\t").append(allTokenCount);
//         result.append("\t").append(mainTokenCount);
//     }
// 
//     public IndexInfo(final String[] fields, int i) {
//         shortName = fields[i++];
//         allTokenCount = Integer.parseInt(fields[i++]);
//         mainTokenCount = Integer.parseInt(fields[i++]);
//     }
// }
// 
// Path: src/com/hughes/android/dictionary/engine/Language.java
// public static final class LanguageResources {
//     final String englishName;
//     public final int nameId;
//     public final int flagId;
// 
//     public LanguageResources(final String englishName, int nameId, int flagId) {
//         this.englishName = englishName;
//         this.nameId = nameId;
//         this.flagId = flagId;
//     }
// 
//     public LanguageResources(final String englishName, int nameId) {
//         this(englishName, nameId, 0);
//     }
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
import com.hughes.android.dictionary.engine.Language.LanguageResources;
        isoCodeToResources.put("TA", new LanguageResources("Tamil", R.string.TA));
        isoCodeToResources.put("SH", new LanguageResources("Serbo-Croatian", R.string.SH));
        isoCodeToResources.put("SD", new LanguageResources("Sindhi", R.string.SD));

        // Hack to allow lower-case ISO codes to work:
        for (final String isoCode : new ArrayList<>(isoCodeToResources.keySet())) {
            isoCodeToResources.put(isoCode.toLowerCase(), isoCodeToResources.get(isoCode));
        }
    }

    public int getFlagIdForIsoCode(final String isoCode) {
        LanguageResources res = isoCodeToResources.get(isoCode);
        return res == null ? 0 : res.flagId;
    }

    public String isoCodeToLocalizedLanguageName(final Context context, final String isoCode) {
        String lang = new Locale(isoCode).getDisplayLanguage();
        if (!lang.equals("") && !lang.equals(isoCode))
        {
            return lang;
        }
        final LanguageResources languageResources = isoCodeToResources.get(isoCode);
        if (languageResources != null)
        {
            lang = context.getString(languageResources.nameId);
        }
        return lang;
    }

    public View createButton(final Context context,
// Path: src/com/hughes/android/dictionary/DictionaryInfo.java
// public static final class IndexInfo implements Serializable {
//     private static final long serialVersionUID = 6524751236198309438L;
// 
//     static final int NUM_CSV_FIELDS = 3;
// 
//     public final String shortName; // Often LangISO.
//     final int allTokenCount;
//     public final int mainTokenCount;
// 
//     public IndexInfo(String shortName, int allTokenCount, int mainTokenCount) {
//         this.shortName = shortName;
//         this.allTokenCount = allTokenCount;
//         this.mainTokenCount = mainTokenCount;
//     }
// 
//     void append(StringBuilder result) {
//         result.append(shortName);
//         result.append("\t").append(allTokenCount);
//         result.append("\t").append(mainTokenCount);
//     }
// 
//     public IndexInfo(final String[] fields, int i) {
//         shortName = fields[i++];
//         allTokenCount = Integer.parseInt(fields[i++]);
//         mainTokenCount = Integer.parseInt(fields[i++]);
//     }
// }
// 
// Path: src/com/hughes/android/dictionary/engine/Language.java
// public static final class LanguageResources {
//     final String englishName;
//     public final int nameId;
//     public final int flagId;
// 
//     public LanguageResources(final String englishName, int nameId, int flagId) {
//         this.englishName = englishName;
//         this.nameId = nameId;
//         this.flagId = flagId;
//     }
// 
//     public LanguageResources(final String englishName, int nameId) {
//         this(englishName, nameId, 0);
//     }
// }


// Path: src/com/hughes/android/dictionary/IsoUtils.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
import com.hughes.android.dictionary.engine.Language.LanguageResources;

        isoCodeToResources.put("TA", new LanguageResources("Tamil", R.string.TA));
        isoCodeToResources.put("SH", new LanguageResources("Serbo-Croatian", R.string.SH));
        isoCodeToResources.put("SD", new LanguageResources("Sindhi", R.string.SD));

        // Hack to allow lower-case ISO codes to work:
        for (final String isoCode : new ArrayList<>(isoCodeToResources.keySet())) {
            isoCodeToResources.put(isoCode.toLowerCase(), isoCodeToResources.get(isoCode));
        }
    }

    public int getFlagIdForIsoCode(final String isoCode) {
        LanguageResources res = isoCodeToResources.get(isoCode);
        return res == null ? 0 : res.flagId;
    }

    public String isoCodeToLocalizedLanguageName(final Context context, final String isoCode) {
        String lang = new Locale(isoCode).getDisplayLanguage();
        if (!lang.equals("") && !lang.equals(isoCode))
        {
            return lang;
        }
        final LanguageResources languageResources = isoCodeToResources.get(isoCode);
        if (languageResources != null)
        {
            lang = context.getString(languageResources.nameId);
        }
        return lang;
    }

    public View createButton(final Context context,
                             final IndexInfo indexInfo, int size) {