Class LanguageCatalog
Language definitions plus the global formatting
code points.
Built-in languages live in /languages/<code>.json; the global
formatting list in /languages/formatting.json. A language's file
is parsed only when it is first requested via language(String) -
the plugin reads just the single file it needs.
User-supplied languages are registered per code as a map of
code → file via load(Map). Files are validated lazily: the
code key must match the code declared inside the file (fail-fast
on first access), and the file's code/name/chars
must be well-formed.
-
Method Summary
Modifier and TypeMethodDescriptioncodes()All registered language codes (built-ins plus custom), insertion order.int[]Global formatting code points (sorted, unique,int[]).booleanisFormattingCodePoint(int codePoint) True ifcodePointis in the global formatting set.Look up a language by its code; returnsnullif not present.All languages, keyed by code.static LanguageCatalogCatalog with the built-in languages plus user-supplied per-code files.static LanguageCatalogCatalog with only the built-in languages and formatting.
-
Method Details
-
loadDefaults
Catalog with only the built-in languages and formatting.- Throws:
IllegalStateException- if a resource is missing or malformed
-
load
Catalog with the built-in languages plus user-supplied per-code files.Files are not read here - only their codes are registered; parsing happens lazily on
language(String)so a bad file fails only when its language is actually requested.- Parameters:
customLanguages- code → file;nulland empty map mean "defaults only"- Throws:
IllegalArgumentException- if any code key is blank, its file isnull, or the file is not an existing regular file
-
language
Look up a language by its code; returnsnullif not present.Lazy: the first call for a code parses its file (built-in resource or user-supplied file) and caches the result; later calls are map lookups.
- Throws:
IllegalArgumentException- if a user-supplied file is missing, has a code mismatch, or is malformedIllegalStateException- if a built-in resource is missing or malformed
-
codes
All registered language codes (built-ins plus custom), insertion order. -
languages
All languages, keyed by code.Eager: calling this parses every registered language. Use
codes()when only the codes are needed (error messages, report header), so no files are read unnecessarily. -
formatting
public int[] formatting()Global formatting code points (sorted, unique,int[]). -
isFormattingCodePoint
public boolean isFormattingCodePoint(int codePoint) True ifcodePointis in the global formatting set.
-