DocumentL10n.webidl (2066B)
1 /* -*- Mode: IDL; 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 file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 */ 6 7 /** 8 * DocumentL10n is a public interface for handling DOM localization. 9 * 10 * In it's current form it exposes the DOMLocalization API which 11 * allows for localization-specific DOM operations on a defined 12 * localization context, and retrival of formatted localization 13 * messages out of that context. 14 * 15 * The context is created when `<link rel="localization"/>` elements 16 * are added to the document, and is removed in case all links 17 * of that type are removed from it. 18 */ 19 [LegacyNoInterfaceObject, 20 Exposed=Window] 21 interface DocumentL10n : DOMLocalization { 22 /** 23 * A promise which gets resolved when the initial DOM localization resources 24 * fetching is complete and the initial translation of the DOM is finished. 25 */ 26 readonly attribute Promise<any> ready; 27 28 /** 29 * An overload for the DOMLocalization::connectRoot which takes an optional second 30 * argument to allow the user to express an intent of translating the root 31 * as soon as the localization becomes available. 32 * 33 * If the root is being connected while the document is still being parsed, 34 * then irrelevant of the value of the second argument, it will be translated 35 * as part of the initial translation step right after the parsing completes. 36 * 37 * If the root is being connected after the document is parsed, then the 38 * second argument controls whether the root is also going to get translated, 39 * or just connected. 40 * 41 * This is a temporary workaround to avoid having to wait for the `DocumentL10n` 42 * to become active. It should be unnecessary once we remove JSM and make 43 * the `TranslateFragment` be available immediately when `DocumentL10n` becomes 44 * available. 45 */ 46 [Throws] undefined connectRoot(Node aElement, optional boolean aTranslate = false); 47 };