Skip to content

rmraya/BCP47J

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BCP47J

A library written in Java for handling Language Tags in compliance with BCP47.

This library is part of OpenXLIFF Filters

Usage

Use the static methods provided by class com.maxprograms.languages.LanguageUtils

Method Description
List<Language> getAllLanguages() Returns a list of all languages from BCP47
List<Language> getCommonLanguages() Returns a list of most common languages
Language getLanguage(String code) Returns a language given its code
Language languageFromName(String description) Returns a language given its description
String normalizeCode(String code) Normalizes a language code to the format described in BCP47
boolean isBiDi(String code) Returns true if the language is written right-to-left
boolean isCJK(String code) Returns true if the language is written in CJK script
String[] getLanguageNames() Returns an array with the names of most common languages

Localization

This library includes lists of languages with their names in English, Spanish and French.

Set Locale to en (default), es or fr to get the names in English, Spanish or French respectively.

Locale.setDefault(Locale.forLanguageTag("es"));
String[] names = LanguageUtils.getLanguageNames();

Contact tech@maxprograms.com to localize the names to other languages.

Example

import com.maxprograms.languages.Language;
import com.maxprograms.languages.LanguageUtils;

...

boolean isValidLanguage(String code) {
    return LanguageUtils.getLanguage(code) != null;
}

Building

You need Java 21 and Gradle

  • Point your JAVA_HOME variable to JDK 21
  • Checkout this repository
  • Run gradle to compile the source code
git clone https://github.com/rmraya/BCP47J.git
cd BCP47J
gradle

License

This software is source-available and proprietary.
You may view and modify the source code for personal, educational, or internal evaluation purposes.

Redistribution, commercial use, or distribution of modified versions is prohibited without prior written permission from Maxprograms.

See the LICENSE.md file for full terms.

About

Java library for languages and BCP47

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages