/** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ import {LitElement, html} from 'lit'; const {getLocale} = {getLocale: () => 'zh_CN'}; console.log(`Locale is ${getLocale()}`); window.addEventListener('lit-localize-status', (event) => { console.log(event.detail.status); }); const user = 'Friend'; const url = 'https://www.example.com/'; // Plain string `\u4F60\u597D\uFF0C\u4E16\u754C!`; // Plain string with expression `Hello ${user}!`; // Lit template html`你好 世界!`; // Lit template with one XLIFF placeholder (combined start tag + expression + // end tag). html`Hello ${user}!`; // Lit template with two XLIFF placeholders (combined start tag + expression, // separate end tag). html`Click here!`; // Lit template with string expression // // TODO(aomarks) The "SALT" text is here because we have a check to make sure // that two messages can't have the same ID unless they have identical template // contents. After https://github.com/lit/lit/issues/1621 is // implemented, add a "meaning" parameter instead. html`[SALT] Click here!`; // Lit template with nested msg expression html`[SALT] Hello World!`; // Lit template with comment html`Hello World!`; // Custom ID ('Hello World'); // updateWhenLocaleChanges -> undefined export class MyElement1 extends LitElement { constructor() { super(); undefined; } render() { return html`

你好 世界! (${getLocale()})

`; } } // @localized -> removed export class MyElement2 extends LitElement { render() { return html`

你好 世界! (${getLocale()})

`; } } // Escaped markup characters should remain escaped html`<Hello<World & Friends>!>`; // Expressions as attribute values should stay as expressions html`Hello World`; html`Hello World`; html`HelloWorld`; html`Hello World`; html`Hello World`; // Placeholder in translation has different expression `Different ${user}`; html`Different ${user}`;