getLanguage() function retrieves or creates a Language object that can be used with the lower-level formatting and parsing functions.
Import
Signature
Either a locale string (e.g.,
'en', 'de', 'ru') or a custom LanguageDefinition object.A
Language object with parsing and formatting utilitiesUsage
Get a built-in language
Use with formatting functions
TheLanguage object is primarily used with formatMilliseconds() and parseDuration():
Use with custom language definitions
You can pass a custom language definition directly:Language caching
The function uses an internal cache to avoid recreating language objects. When you callgetLanguage() with the same locale multiple times, it returns the cached Language object:
getLanguage() without performance penalties.
Available locales
The following locale keys are supported:'en'- English'de'- German'ru'- Russian'mi'- Māori'es'- Spanish'nl'- Dutch'it'- Italian'fr'- French'cs'- Czech'pl'- Polish'zh-CN'- Chinese (Simplified)
When to use this function
UsegetLanguage() when:
- Working with
formatMilliseconds()orparseDuration()directly - You need explicit control over the language parameter
- Building custom formatting utilities
createMs() function is more convenient as it creates a function with a pre-configured language.
See also
- formatMilliseconds() - Format milliseconds with a specific language
- parseDuration() - Parse duration strings with a specific language
- createMs() - Create a custom ms instance with a default language
- Languages - Available language definitions