@fluent/bundle
Advanced tools
Comparing version 0.15.0 to 0.15.1
# Changelog | ||
## @fluent/bundle 0.15.0 (January 23, 2019) | ||
## @fluent/bundle 0.15.1 (April 7, 2020) | ||
- Allow only some formatting options to `NUMBER` and `DATETIME`. (#464) | ||
The builtin functions available to translations were liberal in terms of | ||
the options they accepted. This could lead to undesired results, e.g. | ||
when for the same number value, a translation would specify a different | ||
currency than the source language. | ||
The `NUMBER` builtin now only recognizes the following options: | ||
unitDisplay | ||
currencyDisplay | ||
useGrouping | ||
minimumIntegerDigits | ||
minimumFractionDigits | ||
maximumFractionDigits | ||
minimumSignificantDigits | ||
maximumSignificantDigits | ||
The `DATETIME` builtin now only recognizes the following options: | ||
dateStyle | ||
timeStyle | ||
fractionalSecondDigits | ||
dayPeriod | ||
hour12 | ||
weekday | ||
era | ||
year | ||
month | ||
day | ||
hour | ||
minute | ||
second | ||
timeZoneName | ||
All other options are ignored. | ||
## @fluent/bundle 0.15.0 (January 23, 2020) | ||
- Migrate to TypeScript. (#436) | ||
@@ -6,0 +45,0 @@ |
115
compat.js
@@ -1,2 +0,2 @@ | ||
/* @fluent/bundle@0.15.0 */ | ||
/* @fluent/bundle@0.15.1 */ | ||
(function (global, factory) { | ||
@@ -110,3 +110,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
* | ||
* @param value - JavaScript value to wrap. | ||
* @param value The JavaScript value to wrap. | ||
*/ | ||
@@ -124,17 +124,3 @@ constructor(value) { | ||
} | ||
/** | ||
* Format this instance of `FluentType` to a string. | ||
* | ||
* Formatted values are suitable for use outside of the `FluentBundle`. | ||
* This method can use `Intl` formatters available through the `scope` | ||
* argument. | ||
* | ||
* @abstract | ||
*/ | ||
toString(scope) { | ||
throw new Error("Subclasses of FluentType must implement toString."); | ||
} | ||
} | ||
@@ -148,3 +134,3 @@ /** | ||
* Create an instance of `FluentNone` with an optional fallback value. | ||
* @param value - The fallback value of this `FluentNone`. | ||
* @param value The fallback value of this `FluentNone`. | ||
*/ | ||
@@ -167,2 +153,6 @@ constructor() { | ||
* A `FluentType` representing a number. | ||
* | ||
* A `FluentNumber` instance stores the number value of the number it | ||
* represents. It may also store an option bag of options which will be passed | ||
* to `Intl.NumerFormat` when the `FluentNumber` is formatted to a string. | ||
*/ | ||
@@ -174,2 +164,5 @@ | ||
* `Intl.NumberFormat` constructor. | ||
* | ||
* @param value The number value of this `FluentNumber`. | ||
* @param opts Options which will be passed to `Intl.NumberFormat`. | ||
*/ | ||
@@ -199,2 +192,7 @@ constructor(value) { | ||
* A `FluentType` representing a date and time. | ||
* | ||
* A `FluentDateTime` instance stores the number value of the date it | ||
* represents, as a numerical timestamp in milliseconds. It may also store an | ||
* option bag of options which will be passed to `Intl.DateTimeFormat` when the | ||
* `FluentDateTime` is formatted to a string. | ||
*/ | ||
@@ -206,4 +204,5 @@ | ||
* `Intl.DateTimeFormat` constructor. | ||
* @param value - timestamp in milliseconds | ||
* @param opts | ||
* | ||
* @param value The number value of this `FluentDateTime`, in milliseconds. | ||
* @param opts Options which will be passed to `Intl.DateTimeFormat`. | ||
*/ | ||
@@ -649,4 +648,4 @@ constructor(value) { | ||
function values(opts) { | ||
var unwrapped = {}; | ||
function values(opts, allowed) { | ||
var unwrapped = Object.create(null); | ||
@@ -658,3 +657,5 @@ for (var _i = 0, _Object$entries = Object.entries(opts); _i < _Object$entries.length; _i++) { | ||
unwrapped[name] = opt.valueOf(); | ||
if (allowed.includes(name)) { | ||
unwrapped[name] = opt.valueOf(); | ||
} | ||
} | ||
@@ -665,2 +666,32 @@ | ||
var NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"]; | ||
/** | ||
* The implementation of the `NUMBER()` builtin available to translations. | ||
* | ||
* Translations may call the `NUMBER()` builtin in order to specify formatting | ||
* options of a number. For example: | ||
* | ||
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* unitDisplay | ||
* currencyDisplay | ||
* useGrouping | ||
* minimumIntegerDigits | ||
* minimumFractionDigits | ||
* maximumFractionDigits | ||
* minimumSignificantDigits | ||
* maximumSignificantDigits | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `NUMBER()`. | ||
* @param opts The named argments passed to this `NUMBER()`. | ||
*/ | ||
function NUMBER(args, opts) { | ||
@@ -674,3 +705,3 @@ var arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentNumber(arg.valueOf(), _objectSpread2({}, arg.opts, {}, values(opts))); | ||
return new FluentNumber(arg.valueOf(), _objectSpread2({}, arg.opts, {}, values(opts, NUMBER_ALLOWED))); | ||
} | ||
@@ -680,2 +711,38 @@ | ||
} | ||
var DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; | ||
/** | ||
* The implementation of the `DATETIME()` builtin available to translations. | ||
* | ||
* Translations may call the `DATETIME()` builtin in order to specify | ||
* formatting options of a number. For example: | ||
* | ||
* now = It's {DATETIME($today, month: "long")}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* dateStyle | ||
* timeStyle | ||
* fractionalSecondDigits | ||
* dayPeriod | ||
* hour12 | ||
* weekday | ||
* era | ||
* year | ||
* month | ||
* day | ||
* hour | ||
* minute | ||
* second | ||
* timeZoneName | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `DATETIME()`. | ||
* @param opts The named argments passed to this `DATETIME()`. | ||
*/ | ||
function DATETIME(args, opts) { | ||
@@ -689,3 +756,3 @@ var arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentDateTime(arg.valueOf(), _objectSpread2({}, arg.opts, {}, values(opts))); | ||
return new FluentDateTime(arg.valueOf(), _objectSpread2({}, arg.opts, {}, values(opts, DATETIME_ALLOWED))); | ||
} | ||
@@ -692,0 +759,0 @@ |
@@ -14,3 +14,65 @@ /** | ||
import { FluentValue } from "./types.js"; | ||
/** | ||
* The implementation of the `NUMBER()` builtin available to translations. | ||
* | ||
* Translations may call the `NUMBER()` builtin in order to specify formatting | ||
* options of a number. For example: | ||
* | ||
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* unitDisplay | ||
* currencyDisplay | ||
* useGrouping | ||
* minimumIntegerDigits | ||
* minimumFractionDigits | ||
* maximumFractionDigits | ||
* minimumSignificantDigits | ||
* maximumSignificantDigits | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `NUMBER()`. | ||
* @param opts The named argments passed to this `NUMBER()`. | ||
*/ | ||
export declare function NUMBER(args: Array<FluentValue>, opts: Record<string, FluentValue>): FluentValue; | ||
/** | ||
* The implementation of the `DATETIME()` builtin available to translations. | ||
* | ||
* Translations may call the `DATETIME()` builtin in order to specify | ||
* formatting options of a number. For example: | ||
* | ||
* now = It's {DATETIME($today, month: "long")}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* dateStyle | ||
* timeStyle | ||
* fractionalSecondDigits | ||
* dayPeriod | ||
* hour12 | ||
* weekday | ||
* era | ||
* year | ||
* month | ||
* day | ||
* hour | ||
* minute | ||
* second | ||
* timeZoneName | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `DATETIME()`. | ||
* @param opts The named argments passed to this `DATETIME()`. | ||
*/ | ||
export declare function DATETIME(args: Array<FluentValue>, opts: Record<string, FluentValue>): FluentValue; |
@@ -14,9 +14,49 @@ /** | ||
import { FluentNone, FluentNumber, FluentDateTime } from "./types.js"; | ||
function values(opts) { | ||
const unwrapped = {}; | ||
function values(opts, allowed) { | ||
const unwrapped = Object.create(null); | ||
for (const [name, opt] of Object.entries(opts)) { | ||
unwrapped[name] = opt.valueOf(); | ||
if (allowed.includes(name)) { | ||
unwrapped[name] = opt.valueOf(); | ||
} | ||
} | ||
return unwrapped; | ||
} | ||
const NUMBER_ALLOWED = [ | ||
"unitDisplay", | ||
"currencyDisplay", | ||
"useGrouping", | ||
"minimumIntegerDigits", | ||
"minimumFractionDigits", | ||
"maximumFractionDigits", | ||
"minimumSignificantDigits", | ||
"maximumSignificantDigits", | ||
]; | ||
/** | ||
* The implementation of the `NUMBER()` builtin available to translations. | ||
* | ||
* Translations may call the `NUMBER()` builtin in order to specify formatting | ||
* options of a number. For example: | ||
* | ||
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* unitDisplay | ||
* currencyDisplay | ||
* useGrouping | ||
* minimumIntegerDigits | ||
* minimumFractionDigits | ||
* maximumFractionDigits | ||
* minimumSignificantDigits | ||
* maximumSignificantDigits | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `NUMBER()`. | ||
* @param opts The named argments passed to this `NUMBER()`. | ||
*/ | ||
export function NUMBER(args, opts) { | ||
@@ -28,6 +68,59 @@ let arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentNumber(arg.valueOf(), { ...arg.opts, ...values(opts) }); | ||
return new FluentNumber(arg.valueOf(), { | ||
...arg.opts, | ||
...values(opts, NUMBER_ALLOWED) | ||
}); | ||
} | ||
throw new TypeError("Invalid argument to NUMBER"); | ||
} | ||
const DATETIME_ALLOWED = [ | ||
"dateStyle", | ||
"timeStyle", | ||
"fractionalSecondDigits", | ||
"dayPeriod", | ||
"hour12", | ||
"weekday", | ||
"era", | ||
"year", | ||
"month", | ||
"day", | ||
"hour", | ||
"minute", | ||
"second", | ||
"timeZoneName", | ||
]; | ||
/** | ||
* The implementation of the `DATETIME()` builtin available to translations. | ||
* | ||
* Translations may call the `DATETIME()` builtin in order to specify | ||
* formatting options of a number. For example: | ||
* | ||
* now = It's {DATETIME($today, month: "long")}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* dateStyle | ||
* timeStyle | ||
* fractionalSecondDigits | ||
* dayPeriod | ||
* hour12 | ||
* weekday | ||
* era | ||
* year | ||
* month | ||
* day | ||
* hour | ||
* minute | ||
* second | ||
* timeZoneName | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `DATETIME()`. | ||
* @param opts The named argments passed to this `DATETIME()`. | ||
*/ | ||
export function DATETIME(args, opts) { | ||
@@ -39,5 +132,8 @@ let arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentDateTime(arg.valueOf(), { ...arg.opts, ...values(opts) }); | ||
return new FluentDateTime(arg.valueOf(), { | ||
...arg.opts, | ||
...values(opts, DATETIME_ALLOWED) | ||
}); | ||
} | ||
throw new TypeError("Invalid argument to DATETIME"); | ||
} |
@@ -11,3 +11,3 @@ import { Scope } from "./scope.js"; | ||
*/ | ||
export declare class FluentType<T> { | ||
export declare abstract class FluentType<T> { | ||
/** The wrapped native value. */ | ||
@@ -18,3 +18,3 @@ value: T; | ||
* | ||
* @param value - JavaScript value to wrap. | ||
* @param value The JavaScript value to wrap. | ||
*/ | ||
@@ -32,6 +32,4 @@ constructor(value: T); | ||
* argument. | ||
* | ||
* @abstract | ||
*/ | ||
toString(scope: Scope): string; | ||
abstract toString(scope: Scope): string; | ||
} | ||
@@ -44,3 +42,3 @@ /** | ||
* Create an instance of `FluentNone` with an optional fallback value. | ||
* @param value - The fallback value of this `FluentNone`. | ||
* @param value The fallback value of this `FluentNone`. | ||
*/ | ||
@@ -55,5 +53,9 @@ constructor(value?: string); | ||
* A `FluentType` representing a number. | ||
* | ||
* A `FluentNumber` instance stores the number value of the number it | ||
* represents. It may also store an option bag of options which will be passed | ||
* to `Intl.NumerFormat` when the `FluentNumber` is formatted to a string. | ||
*/ | ||
export declare class FluentNumber extends FluentType<number> { | ||
/** Options passed to Intl.NumberFormat. */ | ||
/** Options passed to `Intl.NumberFormat`. */ | ||
opts: Intl.NumberFormatOptions; | ||
@@ -63,2 +65,5 @@ /** | ||
* `Intl.NumberFormat` constructor. | ||
* | ||
* @param value The number value of this `FluentNumber`. | ||
* @param opts Options which will be passed to `Intl.NumberFormat`. | ||
*/ | ||
@@ -73,5 +78,10 @@ constructor(value: number, opts?: Intl.NumberFormatOptions); | ||
* A `FluentType` representing a date and time. | ||
* | ||
* A `FluentDateTime` instance stores the number value of the date it | ||
* represents, as a numerical timestamp in milliseconds. It may also store an | ||
* option bag of options which will be passed to `Intl.DateTimeFormat` when the | ||
* `FluentDateTime` is formatted to a string. | ||
*/ | ||
export declare class FluentDateTime extends FluentType<number> { | ||
/** Options passed to Intl.DateTimeFormat. */ | ||
/** Options passed to `Intl.DateTimeFormat`. */ | ||
opts: Intl.DateTimeFormatOptions; | ||
@@ -81,4 +91,5 @@ /** | ||
* `Intl.DateTimeFormat` constructor. | ||
* @param value - timestamp in milliseconds | ||
* @param opts | ||
* | ||
* @param value The number value of this `FluentDateTime`, in milliseconds. | ||
* @param opts Options which will be passed to `Intl.DateTimeFormat`. | ||
*/ | ||
@@ -85,0 +96,0 @@ constructor(value: number, opts?: Intl.DateTimeFormatOptions); |
@@ -12,3 +12,3 @@ /** | ||
* | ||
* @param value - JavaScript value to wrap. | ||
* @param value The JavaScript value to wrap. | ||
*/ | ||
@@ -24,14 +24,2 @@ constructor(value) { | ||
} | ||
/** | ||
* Format this instance of `FluentType` to a string. | ||
* | ||
* Formatted values are suitable for use outside of the `FluentBundle`. | ||
* This method can use `Intl` formatters available through the `scope` | ||
* argument. | ||
* | ||
* @abstract | ||
*/ | ||
toString(scope) { | ||
throw new Error("Subclasses of FluentType must implement toString."); | ||
} | ||
} | ||
@@ -44,3 +32,3 @@ /** | ||
* Create an instance of `FluentNone` with an optional fallback value. | ||
* @param value - The fallback value of this `FluentNone`. | ||
* @param value The fallback value of this `FluentNone`. | ||
*/ | ||
@@ -59,2 +47,6 @@ constructor(value = "???") { | ||
* A `FluentType` representing a number. | ||
* | ||
* A `FluentNumber` instance stores the number value of the number it | ||
* represents. It may also store an option bag of options which will be passed | ||
* to `Intl.NumerFormat` when the `FluentNumber` is formatted to a string. | ||
*/ | ||
@@ -65,2 +57,5 @@ export class FluentNumber extends FluentType { | ||
* `Intl.NumberFormat` constructor. | ||
* | ||
* @param value The number value of this `FluentNumber`. | ||
* @param opts Options which will be passed to `Intl.NumberFormat`. | ||
*/ | ||
@@ -87,2 +82,7 @@ constructor(value, opts = {}) { | ||
* A `FluentType` representing a date and time. | ||
* | ||
* A `FluentDateTime` instance stores the number value of the date it | ||
* represents, as a numerical timestamp in milliseconds. It may also store an | ||
* option bag of options which will be passed to `Intl.DateTimeFormat` when the | ||
* `FluentDateTime` is formatted to a string. | ||
*/ | ||
@@ -93,4 +93,5 @@ export class FluentDateTime extends FluentType { | ||
* `Intl.DateTimeFormat` constructor. | ||
* @param value - timestamp in milliseconds | ||
* @param opts | ||
* | ||
* @param value The number value of this `FluentDateTime`, in milliseconds. | ||
* @param opts Options which will be passed to `Intl.DateTimeFormat`. | ||
*/ | ||
@@ -97,0 +98,0 @@ constructor(value, opts = {}) { |
141
index.js
@@ -1,2 +0,2 @@ | ||
/* @fluent/bundle@0.15.0 */ | ||
/* @fluent/bundle@0.15.1 */ | ||
(function (global, factory) { | ||
@@ -19,3 +19,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
* | ||
* @param value - JavaScript value to wrap. | ||
* @param value The JavaScript value to wrap. | ||
*/ | ||
@@ -31,14 +31,2 @@ constructor(value) { | ||
} | ||
/** | ||
* Format this instance of `FluentType` to a string. | ||
* | ||
* Formatted values are suitable for use outside of the `FluentBundle`. | ||
* This method can use `Intl` formatters available through the `scope` | ||
* argument. | ||
* | ||
* @abstract | ||
*/ | ||
toString(scope) { | ||
throw new Error("Subclasses of FluentType must implement toString."); | ||
} | ||
} | ||
@@ -51,3 +39,3 @@ /** | ||
* Create an instance of `FluentNone` with an optional fallback value. | ||
* @param value - The fallback value of this `FluentNone`. | ||
* @param value The fallback value of this `FluentNone`. | ||
*/ | ||
@@ -66,2 +54,6 @@ constructor(value = "???") { | ||
* A `FluentType` representing a number. | ||
* | ||
* A `FluentNumber` instance stores the number value of the number it | ||
* represents. It may also store an option bag of options which will be passed | ||
* to `Intl.NumerFormat` when the `FluentNumber` is formatted to a string. | ||
*/ | ||
@@ -72,2 +64,5 @@ class FluentNumber extends FluentType { | ||
* `Intl.NumberFormat` constructor. | ||
* | ||
* @param value The number value of this `FluentNumber`. | ||
* @param opts Options which will be passed to `Intl.NumberFormat`. | ||
*/ | ||
@@ -94,2 +89,7 @@ constructor(value, opts = {}) { | ||
* A `FluentType` representing a date and time. | ||
* | ||
* A `FluentDateTime` instance stores the number value of the date it | ||
* represents, as a numerical timestamp in milliseconds. It may also store an | ||
* option bag of options which will be passed to `Intl.DateTimeFormat` when the | ||
* `FluentDateTime` is formatted to a string. | ||
*/ | ||
@@ -100,4 +100,5 @@ class FluentDateTime extends FluentType { | ||
* `Intl.DateTimeFormat` constructor. | ||
* @param value - timestamp in milliseconds | ||
* @param opts | ||
* | ||
* @param value The number value of this `FluentDateTime`, in milliseconds. | ||
* @param opts Options which will be passed to `Intl.DateTimeFormat`. | ||
*/ | ||
@@ -417,9 +418,49 @@ constructor(value, opts = {}) { | ||
*/ | ||
function values(opts) { | ||
const unwrapped = {}; | ||
function values(opts, allowed) { | ||
const unwrapped = Object.create(null); | ||
for (const [name, opt] of Object.entries(opts)) { | ||
unwrapped[name] = opt.valueOf(); | ||
if (allowed.includes(name)) { | ||
unwrapped[name] = opt.valueOf(); | ||
} | ||
} | ||
return unwrapped; | ||
} | ||
const NUMBER_ALLOWED = [ | ||
"unitDisplay", | ||
"currencyDisplay", | ||
"useGrouping", | ||
"minimumIntegerDigits", | ||
"minimumFractionDigits", | ||
"maximumFractionDigits", | ||
"minimumSignificantDigits", | ||
"maximumSignificantDigits", | ||
]; | ||
/** | ||
* The implementation of the `NUMBER()` builtin available to translations. | ||
* | ||
* Translations may call the `NUMBER()` builtin in order to specify formatting | ||
* options of a number. For example: | ||
* | ||
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* unitDisplay | ||
* currencyDisplay | ||
* useGrouping | ||
* minimumIntegerDigits | ||
* minimumFractionDigits | ||
* maximumFractionDigits | ||
* minimumSignificantDigits | ||
* maximumSignificantDigits | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `NUMBER()`. | ||
* @param opts The named argments passed to this `NUMBER()`. | ||
*/ | ||
function NUMBER(args, opts) { | ||
@@ -431,6 +472,59 @@ let arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentNumber(arg.valueOf(), { ...arg.opts, ...values(opts) }); | ||
return new FluentNumber(arg.valueOf(), { | ||
...arg.opts, | ||
...values(opts, NUMBER_ALLOWED) | ||
}); | ||
} | ||
throw new TypeError("Invalid argument to NUMBER"); | ||
} | ||
const DATETIME_ALLOWED = [ | ||
"dateStyle", | ||
"timeStyle", | ||
"fractionalSecondDigits", | ||
"dayPeriod", | ||
"hour12", | ||
"weekday", | ||
"era", | ||
"year", | ||
"month", | ||
"day", | ||
"hour", | ||
"minute", | ||
"second", | ||
"timeZoneName", | ||
]; | ||
/** | ||
* The implementation of the `DATETIME()` builtin available to translations. | ||
* | ||
* Translations may call the `DATETIME()` builtin in order to specify | ||
* formatting options of a number. For example: | ||
* | ||
* now = It's {DATETIME($today, month: "long")}. | ||
* | ||
* The implementation expects an array of `FluentValues` representing the | ||
* positional arguments, and an object of named `FluentValues` representing the | ||
* named parameters. | ||
* | ||
* The following options are recognized: | ||
* | ||
* dateStyle | ||
* timeStyle | ||
* fractionalSecondDigits | ||
* dayPeriod | ||
* hour12 | ||
* weekday | ||
* era | ||
* year | ||
* month | ||
* day | ||
* hour | ||
* minute | ||
* second | ||
* timeZoneName | ||
* | ||
* Other options are ignored. | ||
* | ||
* @param args The positional arguments passed to this `DATETIME()`. | ||
* @param opts The named argments passed to this `DATETIME()`. | ||
*/ | ||
function DATETIME(args, opts) { | ||
@@ -442,3 +536,6 @@ let arg = args[0]; | ||
if (arg instanceof FluentNumber || arg instanceof FluentDateTime) { | ||
return new FluentDateTime(arg.valueOf(), { ...arg.opts, ...values(opts) }); | ||
return new FluentDateTime(arg.valueOf(), { | ||
...arg.opts, | ||
...values(opts, DATETIME_ALLOWED) | ||
}); | ||
} | ||
@@ -445,0 +542,0 @@ throw new TypeError("Invalid argument to DATETIME"); |
{ | ||
"name": "@fluent/bundle", | ||
"description": "Localization library for expressive translations.", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"homepage": "https://projectfluent.org", | ||
@@ -6,0 +6,0 @@ "author": "Mozilla <l10n-drivers@mozilla.org>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176192
3942
21