All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Internal refactoring.
- Bumped versions of deps
-
[BREAKING] Lit dependency upgraded to v2.
-
[BREAKING] The
Localized
mixin has been replaced with the@localized
decorator and theupdateWhenLocaleChanges
function. These APIs register a Lit 2 controller that serves the same purpose as the removed mixin.import {LitElement} from 'lit-element'; import {Localized} from '@lit/localize/localized-element.js'; class MyElement extends Localized(LitElement) {}
import {LitElement, customElement} from 'lit'; import {localized} from '@lit/localize'; @localized() @customElement('my-element'); class MyElement extends LitElement {}
import {LitElement} from 'lit'; import {updateWhenLocaleChanges} from '@lit/localize'; class MyElement extends LitElement { constructor() { super(); updateWhenLocaleChanges(this); } }
- [BREAKING] Description comments (
// msgdesc:
) have been removed in favor of thedesc
option.
Before:
// msgdesc: Home page
class HomePage {
hello() {
// msgdesc: Greeting to Earth
return msg(html`Hello World`);
}
goodbye() {
// msgdesc: Farewell to Earth
return msg(html`Goodbye World`);
}
}
After:
class HomePage {
hello() {
return msg(html`Hello World`, {
desc: 'Home page / Greeting to Earth',
});
}
goodbye() {
return msg(html`Goodbye World`, {
desc: 'Home page / Farewell to Earth',
});
}
}
-
[BREAKING] Lit Localize is now distributed as two packages:
@lit/localize
provides the browser library (msg
,LocalizedElement
, etc.)@lit/localize-tools
provides thelit-localize
CLI.
-
[BREAKING] Templates can now contain arbitrary expressions, and no longer need to be wrapped in a function.
Before:
msg((name) => html`Hello <b>${name}</b>!`, {args: [getUsername()]});
After:
msg(html`Hello <b>${getUsername()}</b>!`);
Plain strings containing expressions must now be tagged with the new
str
tag. This allows lit-localize to access dynamic values at runtime.import {msg, str} from 'lit-localize'; msg(str`Hello ${name}`);
-
[BREAKING] The
lit-localize
CLI now must always take one of two commands:extract
orbuild
. Previously, both of these steps were always performed.
- Added
@lit/localize/lib/rollup.js
module that exports alocaleTransformers
function that can be used to integrate locale transformation into a Rollup build.
- Fixed missing
.js
files from NPM package.
-
[BREAKING] The signature for the
msg
function has changed:Before:
msg(id: string, template: string|TemplateResult|Function, ...args: any[])
After:
msg(template: string|TemplateResult|Function, options?: {id?: string: args?: any[]})
-
It is no longer necessary to provide a message
id
. When omitted, an id will be automatically generated from the string contents of the template.
// msgdesc
descriptions are now correctly emitted as XLIFF<note>
elements, instead of crashing.
- Fixed missing
localized-element.js
andconfig.schema.json
NPM files.
- [BREAKING] NPM package moved from
lit-localize
to@lit/localize
.
- Fixed
main
field ofpackage.json
so that it resolves tolit-localize.js
instead of non-existent file.
- Add optional
output.localeCodesModule
config file setting which generates a TypeScript module that exportssourceLocale
,targetLocales
, andallLocales
using the locale codes from your config file. Use for keeping your config file and client config in sync.
-
[BREAKING] Published module paths have changed:
lib_client/index.js
->lit-localize.js
lib_client/localized-element.js
->localized-element.js
-
When writing TypeScript, XLIFF, and XLB files, parent directories will now be created automatically, instead of erroring.
-
[BREAKING] The
msg
function has moved from the generatedlocalization.ts
module to the staticlit-localize
module.localization.ts
is no longer generated, and all of its exports have been replaced by a substantially different API (see the README). -
[BREAKING] The initial locale is no longer automatically initialized from the
locale
URL parameter. Initializing/changing locales is now user-controlled. -
[BREAKING] The
tsOut
config file option is replaced by the newoutput
object, withmode: "runtime"|"transform"
.
-
Add
transform
output mode, which emits an entire copy of the program in each locale, where allmsg
calls have been replaced with the raw translated template for that locale. -
Add
configureLocalization
function, which returns asetLocale
andgetLocale
object. -
Add
lit-localize-status
event, which is dispatched towindow
whenever a locale change starts, completes, or fails. -
Add
Localized
mixin forLitElement
components, which automatically re-renders whenever the locale changes inruntime
mode.
-
Fix incorrect JSON schema error about
targetLocales
field not being astring[]
. -
Fix bug where
html
templates could not contain<!-- comments -->
. HTML comments are now preserved as placeholders, similar to other HTML markup.
- Fix missing
<xliff>
element in XLIFF output. - Formatting change to XML output (e.g. fewer line breaks).
- Fix incorrect path resolution when loading XLB files.
- Fix errors relating to prettier xml plugin resolution.
- Add missing dependencies (
fs-extra
,typescript
,prettier
).
-
Add support for the XLIFF localization interchange format: https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
-
[BREAKING] Replaced
xlbDir
config file property withinterchange
property. The interchange format is set withinterchange.format
(currentlyxliff
orxlb
), and other format-specific configuration is set in that object. -
Fix code generation bug where having more than one
targetLocale
would compile to invalid TypeScript (extra commas). -
Disable eslint warnings about camelcase for locale module imports like
zh_CN.ts
.
-
Add support for variables:
msg( 'hello', (url: string, name: string) => html`Hello ${name}, click <a href="${url}">here</a>!`, 'World', 'https://www.example.com/' );
-
Interpret paths as relative to the location of the config file, instead of relative to the current working directory.
-
Move
@types
packages fromdependencies
todevDependencies
if they aren't part of any API. In particular, this fixes an error where any package that depended onlit-localize
would need to addDOM
to their TypeScriptlib
settings for compatibility with@types/xmldom
. -
Publish
.d.ts
files.
- Initial release of
lit-localize
.