plugin:swedish-words
- Description:
- Plugin with various Swedish dictionary methods. All methods can handle basic decompunding of noun phrases.
Methods
(static) currencyHook()
- Description:
- Uses krona/kronor rather than Swedish krona/kronor as currency name when locale is sv-SE
Example
sv
// returns '100 kronor'
currency(100, "SEK")
(static) dateArticleHook()
- Description:
- Adds a format: article option to date outputs This method is highly experimental.
Example
sv
// returns 'den 3 december'
dayMonth("2022-12-03", "article")
(static) form(word, decl, optsopt)
EXPERIMENTAL
- Description:
- Find a declination in a dictionary.
Numerus can be 'sg'/'pl' (Saldo) or 'one'/'many' (CLDR)
Case can be 'nom'/'gen' (Saldo) or 'nominative'/'genitive' (CLDR)
Species can be 'def'/'indef' (Saldo)
This method is highly experimental.
- Find a declination in a dictionary.
Numerus can be 'sg'/'pl' (Saldo) or 'one'/'many' (CLDR)
Example
sv
// returns 'enhörningar'
form("enhörning", "pl")
// returns 'enhörningarna'
form("enhörning", "pl def")
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
word |
string | A word to find the right declination for | |||||||||
decl |
'sg' | 'pl' | 'gen' | 'nom' | 'def' | 'indef|cmp' | A key, Array of, or whitespace sperated list of keys | |||||||||
opts |
object |
<optional> |
Options
Properties
|
(static) fractionOf(val, word, optsopt) → {string}
EXPERIMENTAL
- Description:
- Use dictionary data to construct phrases like ”ett björndjur av fem” This method is highly experimental
Example
sv
// returns '1 av 3 enhörningar'
fractionOf(0.33, "enhörning")
// returns '1 enhörning av 3'
fractionOf(0.33, "enhörning", {variant: "before"})
// returns '1 på 3 chanser'
fractionOf(0.33, "chans", {glue: "på"})
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
val |
number | A count of somethie | ||||||||||||||||||||||||||
word |
string | A word to find the right declination for | ||||||||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A fraction phrase
- Type
- string
(static) fractionOfText(val, word, optsopt) → {string}
EXPERIMENTAL
- Description:
- Use dictionary data to construct phrases like ”ett björndjur av fem” This method is highly experimental
Example
sv
// returns 'en av tre enhörningar'
fractionOfText(0.33, "enhörning")
// returns 'ett av tre bord'
fractionOfText(0.33, "bord")
// returns 'en enhörning av tre'
fractionOfText(0.33, "enhörning", {variant: "before"})
// returns 'en på tre chanser'
fractionOfText(0.33, "chans", {glue: "på"})
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
val |
number | A count of somethie | ||||||||||||||||||||||||||
word |
string | A word to find the right declination for | ||||||||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A fraction phrase
- Type
- string
(static) list()
- Description:
- Adds an option: 'decompound', to decompund lists This method is highly experimental.
Example
sv
// returns 'skönhets-, hälso- och livsstilstidningar'
list(['skönhetstidningar', 'hälsotidningar', 'livsstilstidningar'], "decompund")
(static) namedDay(date, optsopt) → {string}
EXPERIMENTAL
- Description:
- Find the name of a day, e.g. ”Boxing Day” Currently only supported for sv-SE (not sv-AX or sv-FI)
Example
sv-SE
// returns 'nyårsdagen'
namedDay("2020-01-01")
// returns 'den 2 januari'
namedDay("2020-01-02")
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
date |
string | Date | A ISO date string | |
opts |
object |
<optional> |
Options |
Returns:
A named day
- Type
- string
(static) numberOf(val, word, optsopt) → {string}
EXPERIMENTAL
- Description:
- Use dictionary data to combine `number*()` and `plural()` This method is highly experimental
Example
sv
// returns '2 enhörningar'
numberOf(2, "enhörning")
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
val |
number | A count of somethie | ||||||||||||||||
word |
string | A word to find the right declination for | ||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
Formatted compound
- Type
- string
(static) numberOfPretty(val, word, optsopt) → {string}
EXPERIMENTAL
- Description:
- Use dictionary data to combine `number*()` and `plural()` This method is highly experimental
Example
sv
// returns 'två enhörningar'
numberOfPretty(2, "enhörning")
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
val |
number | A count of somethie | ||||||||||||||||||||||||||
word |
string | A word to find the right declination for | ||||||||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
Formatted compound
- Type
- string
(static) numberOfText(val, word, optsopt) → {string}
EXPERIMENTAL
- Description:
- Use dictionary data to combine `number*()` and `plural()` This method is highly experimental
Example
sv
// returns 'en apelsin'
numberOfText(1, "apelsin")
// returns 'ett apelsin'
numberOfText(1, "apelsin", "neuter")
// returns 'två apelsiner'
numberOfText(2, "apelsin")
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
val |
number | A count of something | ||||||||||||||||
word |
string | A word to find the right declination for | ||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
Formatted compound
- Type
- string
(static) plural(number, strings)
- Description:
- Adds dictionary support to plural
Example
sv
// returns '2 enhörningarnas'
plural(2, "enhörningens")
Parameters:
| Name | Type | Description |
|---|---|---|
number |
number | Array | to be counted |
strings |
String | plural forms |
(static) territoryArgHook()
- Description:
- Adds support for full region names as input to territory functions, for Swedish municipalities and counties. This method is highly experimental.
Example
sv
// returns 'Stockholms'
territoryShort("Stockholms kommun", "genitive")
(static) territoryCode(alias) → {string}
EXPERIMENTAL
- Description:
- Get territory code from an alias This method is experimental
Example
sv
// returns 'SE-0604'
territoryCode("Aneby kommun")
Parameters:
| Name | Type | Description |
|---|---|---|
alias |
string | A territory name, eg Borås kommun |
Returns:
A CLDR/textFunctions territory code, e.g. `SE-0423`
- Type
- string
(static) timeHM[S]()
- Description:
- Changes the time format from HH:MM:SS to HH.MM.SS and remove leading zeros, as per most Swedish media styleguides (but unlike CLDR) This method is highly experimental.
Example
sv
// returns '12.14'
timHM("2022-01-08T12:14:13")
// returns '09.14'
timHM("2022-01-08T09:14:13")