java - Converting language names to ISO 639 language codes -


i need convert language names 'hungarian', 'english' iso 639 codes. iso 639-6 best iso 639-2 enough. what's best way achieve this?

i should convert english locale , language getlanguage()? if thats way how can convert string 'english' java locale?

my goal store book language info using iso 639 codes.

you can list of iso 639-2 codes passing regular expression of language names languagealpha3code.findbyname(string) (in nv-i18n library).

the following example code command-line tool converts given language names corresponding iso 639-2 codes.

import java.util.list; import com.neovisionaries.i18n.languagealpha3code;  public class to639_2 {     public static void main(string[] args)     {         // each language name given on command line.         (string languagename : args)         {             // list of iso 639-2 codes (alpha-3 codes)             // language name matches given pattern.             list<languagealpha3code> list                 = languagealpha3code.findbyname(languagename);              // print language , iso 639-2 code.             system.out.format("%s => %s\n", languagename,                 (list.size() != 0) ? list.get(0) : "");         }     } } 

a sample execution:

 $ java -cp nv-i18n-1.14.jar:. to639_2 hungarian english hungarian => hun english => eng 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -