android - How to get the language code based on country code in java -


how language code based on country code in java
hi
had situation need find language based on country code.
country name "switzerland" had country code "ch" .
there can 3 languges german,french , ukenglish in switzerland . need find language code based on country code.
scenario : country code "ch" . need language code based on country code.

thanks in advance

this program prints language codes available locales switzerland. can modified e.g. return list<string> of language codes. picking 1 want left exercise reader - swiss have not chosen pick single preferred language country.

import java.util.locale;  public class test {   public static void main(string[] args) {     locale[] = locale.getavailablelocales();     (locale locale : all) {       string country = locale.getcountry();       if(country.equalsignorecase("ch")){         system.out.println(locale.getlanguage());       }     }   } } 

output:

fr de 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -