-
#4679
eb84bebc
Thanks @codingjoe! - Move localize setup to resolve import loop -
Updated dependencies [
feccc1ba
]:
-
#4326
75943d95
- Loosen type for the@localized()
decorator to be able to decorate anyReactiveControllerHost
which also alleviates type errors that could arise with multiple copies of@lit/reactive-element
present in the project. Also remove dependency on@lit/reactive-element
as it is already covered by thelit
dependency. -
#4299
fffa4406
- Update version range forlit
dependency to include v2 (and/or@lit/reactive-element
v1). This allows projects still on lit v2 to use this package without being forced to install lit v3.
-
Updated dependencies:
-
Updated dependencies [
be72f66b
,dfd747cf
,23c404fd
,1db01376
,6f2833fd
,c3e473b4
,92cedaa2
,7e8491d4
,23326c6b
,f06f7972
]:
- #2188
9fc5a039
- Support emitting generated modules as.js
files. Adds a newoutput.language
setting for runtime mode locale generation, and automatically detects the filetype based on the file extension when usingoutput.localeCodesModule
.
-
Updated dependencies [
ff0d1556
,15a8356d
,2b8dd1c7
,34280cb0
,5768cc60
,018f6520
,5fabe2b5
,0470d86a
,5fabe2b5
,52a47c7e
,5b2f3642
,5fabe2b5
,08f60328
,7adfbb0c
,5fabe2b5
,24feb430
,61fc9452
,5fabe2b5
,13d137e9
,5fabe2b5
,5fabe2b5
,724a9aab
,0312f3e5
,8b6e2415
,761375ac
,a791514b
,5fabe2b5
]:
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.
-
Added
configureReentrantLocalization
ininit/reentrant.js
which allows for safe concurrent rendering across multiple locales by asynchronous tasks, such as in an SSR context.In this configuration, there is no global
setLocale
function. Instead, the caller provides agetLocale
function, which is then called by everymsg
invocation.This pairs well with an asynchronous storage manager like
AsyncLocalStorage
. SeeconfigureSsrLocalization
from@lit/localize-tools/lib/ssr.js
which does exactly this.
- Removed accidental export of
_msg
(usemsg
instead).
- 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 nonexistent 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
.