trying develop a Russian/English Flag game, given the flag image you choose in Russian or in English modes...

Since English country names get from country file image names, can have a Java generic Map key=englishCountryName & value=inRussianEquivalent.... to do the Russian part???

Or exist other way? if you think this is good choice, where insert this COUNTRIES Map<String, String> (about 200 entries) , in an Activity or in a Java file? can/must this Map variable be public static final?

Recommended Answers

All 16 Replies

Since you talking about "Activity" and Java I presume that we are on Android topic. To have various languages in the application you just need to provide localizaton. Read more about it here Localization and Supporting Different Languages

java files can contain russian characters eg on a Map (english the key), (Russian the value)????

No Java files have to be encoded in UTF-8 therefore it is easier to use XML files as Android OS takes care of it

You mean populate, with English (key), & Russian (value) words the Java Maps generic arrays, from xml file...utf-8 coded, this must work?

yes this mean(exactly) / no may not work

what about rather xml, use an txt file.txt?

Did you actually read either of the links I provided?

In my case is easier use a map with ru(values) and en(keys), just tell am I able for this?

You should be, but not come back crying about hell of text in unicode format

java files needed any char encoding statement in Android... go to try now!

Little respect wouldn't hurt! And even Java need Unicode. Or do you care to post particular example to prove me wrong?

I try it well i think it will work... prompt me for convert to utf-8 jave file. are you recomment hard code(populate) the map in java code or read at run time from a file...? countries names en/ru...???

These are two different statements

java files needed any char encoding statement in Android... go to try now!


I try it well i think it will work

I'm not recommending any hard coded maps. I'm telling you to do it properly through resources as xml files. If you not gone listen to my advice do not ask me about map or your chances of russian alphabet in Java

public Map<String, String> enRu;
enRu = new HashMap<String, String>();
enRu.get("key")=gives value ,... 

well if have value how get corresponding key? no double values no double keys... what java map to use?

public static String getKeyByValue(Map<String, String> map, String value) {
    for (String key : map.keySet()) {
        if (value.equals(map.get(key))) {
            return key;
    return null;

How I can hard populate a Map without must space in jave file? exist and other way than
regionsMap.put("Africa", true);

        enRu = new HashMap<String, String>();
        enRu.put("Africa", "Африка");

        textView = (TextView)findViewById(;
        textView.setText(enRu.get("Africa")+" "+getKeyByValue(enRu,"Африка"));

well I went in other WORKSPACE and opeded the file but non-understandable chars appear for russian... if work only in old workspace, and upload apk in my device and works, means works in all phones???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.