new Runtime(mf)
A set of utility functions that are called by the compiled Javascript functions, these are included locally in the output of compile().
Parameters:
Name | Type | Description |
---|---|---|
mf |
MessageFormat | A MessageFormat instance |
- Source:
Methods
number(value, name, offsetopt) → {number|string}
Utility function for #
in plural rules
Will throw an Error if value
has a non-numeric value and offset
is
non-zero or MessageFormat#setStrictNumberSign is set.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
number | The value to operate on |
||
name |
string | The name of the argument, used for error reporting |
||
offset |
number |
<optional> |
0 | An optional offset, set by the surrounding context |
- Source:
Returns:
The result of applying the offset to the input value
- Type
- number | string
plural(value, offset, lcfunc, data, isOrdinalnullable) → {string}
Utility function for {N, plural|selectordinal, ...}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
number | The key to use to find a pluralization rule |
|
offset |
number | An offset to apply to |
|
lcfunc |
function | A locale function from |
|
data |
Object.<string, string> | The object from which results are looked up |
|
isOrdinal |
boolean |
<nullable> |
If true, use ordinal rather than cardinal rules |
- Source:
Returns:
The result of the pluralization
- Type
- string
select(value, data) → {string}
Utility function for {N, select, ...}
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The key to use to find a selection |
data |
Object.<string, string> | The object from which results are looked up |
- Source:
Returns:
The result of the select statement
- Type
- string
setStrictNumber(enableopt)
Set how strictly the number method parses its input.
According to the ICU MessageFormat spec, #
can only be used to replace a
number input of a plural
statement. By default, messageformat.js does not
throw a runtime error if you use non-numeric argument with a plural
rule,
unless rule also includes a non-zero offset
.
This is called by MessageFormat#setStrictNumberSign to follow the stricter ICU MessageFormat spec.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
enable |
boolean |
<optional> |
false |
- Source: