Fluent.webidl (1734B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 dictionary FluentTextElementItem { 7 UTF8String id; 8 UTF8String attr; 9 UTF8String text; 10 }; 11 12 [ChromeOnly, Exposed=Window] 13 interface FluentResource { 14 constructor(UTF8String source); 15 16 [Throws] 17 sequence<FluentTextElementItem> textElements(); 18 }; 19 20 [ChromeOnly, Exposed=Window] 21 interface FluentPattern {}; 22 23 /** 24 * FluentMessage is a structure storing an unresolved L10nMessage, 25 * as returned by the Fluent Bundle. 26 * 27 * It stores a FluentPattern of the value and attributes, which 28 * can be then passed to bundle.formatPattern. 29 */ 30 31 dictionary FluentMessage { 32 FluentPattern? value = null; 33 required record<UTF8String, FluentPattern> attributes; 34 }; 35 36 typedef record<UTF8String, (UTF8String or double)?> L10nArgs; 37 38 dictionary FluentBundleOptions { 39 boolean useIsolating = false; 40 UTF8String pseudoStrategy; 41 }; 42 43 dictionary FluentBundleAddResourceOptions { 44 boolean allowOverrides = false; 45 }; 46 47 [ChromeOnly, Exposed=Window] 48 interface FluentBundle { 49 [Throws] 50 constructor((UTF8String or sequence<UTF8String>) aLocales, optional FluentBundleOptions aOptions = {}); 51 52 [Pure, Cached] 53 readonly attribute sequence<UTF8String> locales; 54 55 undefined addResource(FluentResource aResource, optional FluentBundleAddResourceOptions aOptions = {}); 56 boolean hasMessage(UTF8String id); 57 FluentMessage? getMessage(UTF8String id); 58 [Throws] 59 UTF8String formatPattern(FluentPattern pattern, optional L10nArgs? aArgs = null, optional object aErrors); 60 };