Supported languages
The following languages are currently supported:| Language | Key |
|---|---|
| English (default) | en |
| German | de |
| Russian | ru |
| Māori | mi |
| Spanish | es |
| Dutch | nl |
| Italian | it |
| French | fr |
| Czech | cs |
| Polish | pl |
| Chinese (Simplified) | zh-CN |
languages export
Thelanguages object contains all built-in language definitions.
Usage
You can import the languages object to access individual language definitions:Using languages
You can specify a language when creating an ms instance withcreateMs():
Formatting in different languages
Parsing in different languages
Custom language definitions
You can create a custom language definition by implementing theLanguageDefinition interface:
Language definition structure
Each language definition must include:The decimal separator used in the language (e.g.,
'.' for English, ',' for German).The conjunction word or function used to join duration parts (e.g.,
'and' for English, 'und' for German).Definitions for all time units. Each unit must have:
name: String or function returning the unit name (with pluralization)abbreviation: String or function returning the abbreviated formmatches: Array of lowercase strings used for parsing
Contributing languages
We welcome contributions of new language support! To add a new language:- Create a new file in the
src/languages/directory of the GitHub repository - Follow the structure of existing language files (e.g.,
en.ts) - Include all time units with proper translations
- Add parsing matches for common variations
- Submit a pull request