Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Language to ISO 639-3 codes #29

Open
mdoering opened this issue Oct 8, 2018 · 7 comments
Open

Extend Language to ISO 639-3 codes #29

mdoering opened this issue Oct 8, 2018 · 7 comments

Comments

@mdoering
Copy link
Member

mdoering commented Oct 8, 2018

Based on gbif/checklistbank#73 we need to deal with more languages than the current enum based on ISO 639-2 codes holds. The simplest option would be to extend the Language enum with all ~7700 codes and store both 2 and 3 letter codes as enum properties. But is a large enum like this still a good idea? Enum values are only initialised when they are first used, so should not be a JVM issue

@mdoering
Copy link
Member Author

mdoering commented Oct 8, 2018

we have 186 entries now and use Locale to retrieve an english and native title.
That would also need to be explicitly listed in the extended enum

@mdoering
Copy link
Member Author

mdoering commented Oct 8, 2018

The official list has only english titles: https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3.tab

@mdoering
Copy link
Member Author

mdoering commented Oct 8, 2018

I've quickly tried an extended enum and its not gonna work. Compilation error "Java code too large"

@marcos-lg
Copy link
Contributor

This will be covered in #51

@MattBlissett
Copy link
Member

MattBlissett commented Aug 26, 2020

Proposal:

Use java.util.Locale, with the property name languageTag, and serialize using BCP-47 (.toLanguageTag()). Alternatively, store just a String languageTag, specified to be BCP-47, and parse using Locale.

This seems to support pretty much everything, and moves the question of what values should be allowed to the classes. "Website language" might need 6+ constants defined, "User language" would need a list of living languages, and checklists can record any language -- it's up to the parser to decide what to do with fr, fr-LU and fr-FR.

new Locale.Builder()
  .setLanguage("zh").setScript("Hant").build().toLanguageTag() 
→ "zh-Hant"

new Locale.Builder()
  .setLanguage("es").setRegion("419").build().getDisplayName() 
→ "Spanish (Latin America and the Caribbean)"

// All the bits for Locale("en", "GB"):
en_GB
en
English
英文  // getDisplayLanguage(Locale.SIMPLIFIED_CHINESE)
GB
United Kingdom
English (United Kingdom)
eng
// (no script)
en-GB // toLanguageTag()

@MattBlissett
Copy link
Member

MattBlissett commented Aug 26, 2020

I've run all the Crowdin language through Locale.Builder()... and it works. Crowdin include Klingon, en_JA (Jamaica is JM, and en_JM is present and works) and some other non-ISO codes. They can be stored in a Locale and retrieved, but the meanings might not be in Locale's dictionary.

All the GBIF Language enumeration values parse fine.

@mike-podolskiy90
Copy link
Contributor

I'll try GbifUser with the Locale. Do we have add locale to the Organization class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants