Android Open Source - Arvutaja Localized Strings






From Project

Back to project page Arvutaja.

License

The source code is released under:

Apache License

If you think the Android project Arvutaja listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ee.ioc.phon.android.arvutaja;
//  w  ww .ja  va2s.c o m
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * TODO: If we could (easily) query the resources by locale, then this class would not be needed.
 */
public class LocalizedStrings {

  private static final Map<Integer, String> STRINGS_ET;
  private static final Map<Integer, String> STRINGS_EN;
  private static final Map<String, Map<Integer, String>> STRINGS;

  static {
    Map<Integer, String> aMapEt = new HashMap<Integer, String>();
    aMapEt.put(R.string.equals, "on");
    aMapEt.put(R.string.ambiguous, "Sisend on mitmene: %d avaldist.");
    aMapEt.put(R.string.errorResultNoMatch, "Sisendkne transkribeerimine luhtus. Proovige uuesti!");
    STRINGS_ET = Collections.unmodifiableMap(aMapEt);

    Map<Integer, String> aMapEn = new HashMap<Integer, String>();
    aMapEn.put(R.string.equals, "equals");
    aMapEn.put(R.string.ambiguous, "Input is ambiguous between %d readings.");
    aMapEn.put(R.string.errorResultNoMatch, "No match was found for the recorded speech. Please try again!");
    STRINGS_EN = Collections.unmodifiableMap(aMapEn);

    Map<String, Map<Integer, String>> aMap = new HashMap<String, Map<Integer, String>>();
    aMap.put("et", STRINGS_ET);
    aMap.put("en", STRINGS_EN);
    STRINGS = Collections.unmodifiableMap(aMap);
  }

  public static String getString(Locale locale, int resId) {
    Map<Integer, String> map = STRINGS.get(locale.getLanguage().substring(0, 2));
    if (map == null) {
      return null;
    }
    return map.get(resId);
  }

  public static String getString(Locale locale, int resId, Object... formatArgs) {
    Map<Integer, String> map = STRINGS.get(locale.getLanguage().substring(0, 2));
    if (map == null) {
      return null;
    }
    String format = map.get(resId);
    if (format == null) {
      return null;
    }
    return String.format(locale, format, formatArgs);
  }
}




Java Source Code List

ee.ioc.phon.android.arvutaja.AbstractRecognizerActivity.java
ee.ioc.phon.android.arvutaja.Animations.java
ee.ioc.phon.android.arvutaja.ArvutajaActivity.java
ee.ioc.phon.android.arvutaja.AudioCue.java
ee.ioc.phon.android.arvutaja.Constants.java
ee.ioc.phon.android.arvutaja.ExamplesActivity.java
ee.ioc.phon.android.arvutaja.Executable.java
ee.ioc.phon.android.arvutaja.LocalizedStrings.java
ee.ioc.phon.android.arvutaja.Log.java
ee.ioc.phon.android.arvutaja.MicButton.java
ee.ioc.phon.android.arvutaja.SettingsActivity.java
ee.ioc.phon.android.arvutaja.SettingsFragment.java
ee.ioc.phon.android.arvutaja.ShowActivity.java
ee.ioc.phon.android.arvutaja.SubActivity.java
ee.ioc.phon.android.arvutaja.Utils.java
ee.ioc.phon.android.arvutaja.command.Alarm.java
ee.ioc.phon.android.arvutaja.command.CommandParseException.java
ee.ioc.phon.android.arvutaja.command.CommandParser.java
ee.ioc.phon.android.arvutaja.command.Command.java
ee.ioc.phon.android.arvutaja.command.DefaultCommand.java
ee.ioc.phon.android.arvutaja.command.Dial.java
ee.ioc.phon.android.arvutaja.command.Direction.java
ee.ioc.phon.android.arvutaja.command.Expr.java
ee.ioc.phon.android.arvutaja.command.MathEval.java
ee.ioc.phon.android.arvutaja.command.Search.java
ee.ioc.phon.android.arvutaja.command.Unitconv.java
ee.ioc.phon.android.arvutaja.command.View.java
ee.ioc.phon.android.arvutaja.command.WebSearch.java
ee.ioc.phon.android.arvutaja.provider.ArvutajaAppWidgetProvider.java
ee.ioc.phon.android.arvutaja.provider.Qeval.java
ee.ioc.phon.android.arvutaja.provider.QueriesContentProvider.java
ee.ioc.phon.android.arvutaja.provider.Query.java