Skip to content

Library for handling language in APIs from Global Digital Library

License

Notifications You must be signed in to change notification settings

GlobalDigitalLibraryio/language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LANGUAGE

Library for handling language in APIs from Global Digital Library.

Usage

Add dependency to this library: "gdl" %% "language" % "<version>",

The main way of using this library is with the case class LanguageTag. It accepts a string as input on the format <LanguageCode>[-<Script>[-<Region>]]

  • LanguageCode is required, and supports iso639-1/2/3
  • Script is optional, but if used must be a valid iso1924 value
  • Region is optional, but if used must be a valid iso3155 value

A LanguageNotSupportedException will be thrown if the string given as input is not valid.

Example:

class MyClass {
   def doSomeLanguageHandling = {
      val tag1 = LanguageTag("amh")
      val tag2 = LanguageTag("en-latn-gb")
      val tag3 = LanguageTag("eng-gb")
      
      println(tag1)
      println(tag1.displayName)
      println(tag2)
      println(tag2.displayName)
      println(tag3) 
      println(tag3.displayName)
   }
}

Output from the above println

"amh"
"Amharic"
"eng-latn-gb"
"English (Latin, United Kingdom)
"eng-gb"
"English (United Kingdom)"

Building and distribution

Updating the library, when standards change

The following files are the used as input to this library:

To update this library, download the above mentioned files, and run ./generator/generate.py

This will regenerate the content of CodeLists and adjacent files.

Compile

sbt compile

Run tests

sbt test

Build

./build.sh

Publish

./release.sh

About

Library for handling language in APIs from Global Digital Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages