test.html (1052B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test DocumentL10n in HTML environment</title> 6 <link rel="localization" href="test.ftl"/> 7 <script type="text/javascript"> 8 document.testsReadyPromise = new Promise((resolve) => { 9 // The test is in this file to ensure that we're testing 10 // the behavior in a non-system principal. 11 document.addEventListener("DOMContentLoaded", async () => { 12 await document.l10n.ready; 13 14 // Assign the localization from JS 15 let label = document.getElementById("label1"); 16 document.l10n.setAttributes( 17 label, 18 "subtitle", 19 { 20 name: "Firefox", 21 } 22 ); 23 24 const customMsg = await document.l10n.formatValue("custom-message"); 25 document.getElementById("customMessage").textContent = customMsg; 26 resolve(); 27 }, {once: true}); 28 }); 29 </script> 30 </head> 31 <body> 32 <h1 id="main-desc" data-l10n-id="page-title"></h1> 33 34 <p id="label1"></p> 35 <p id="customMessage"></p> 36 </body> 37 </html>