---
title: "lit-localize"
description: "The preset for @lit/localize. It reads msg() with str and html, computes the same ids as lit-localize, and reads XLIFF per target locale."
canonical_url: "https://x18n.dev/presets/lit-localize"
---
# lit-localize

> The preset for @lit/localize. It reads msg() with str and html, computes the same ids as lit-localize, and reads XLIFF per target locale.

The `lit-localize` preset supports [`@lit/localize`](https://lit.dev/docs/localization/overview/) in its XLIFF mode.

## Detection

The preset applies when the project depends on `@lit/localize`.

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: ['lit-localize'],
})
```

## Locale files

`lit-localize.json` gives `sourceLocale` and `interchange.xliffDir` (`xliff` by default), and each `{locale}.xlf` there is a target locale. `lit-localize` has no file for the source locale, so x18n reads the source text from the `<source>` of a target file. That reading is read-only: the source text lives in your code. Run `lit-localize extract` to add new messages to the files.

## Supported syntax

```ts [src/a.ts]
msg('Hello World')
msg(str`Hello ${name}`, { desc: 'A greeting' })
msg(html`Hello <b>World</b>`)
msg('Buffalo', { id: 'buffalo-animal' })
```

A message without an `id` gets the id `lit-localize` computes from its text and its tag. `desc` is its description for translators. Only files that mention `@lit/localize` are read.

## Placeholders

`{$0}`, `{$1}`: the numbered `<x>` elements of the XLIFF file, in order.


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
