Skip to content

document localization template interpolation, like ${0} #1404

Open
@jimmont

Description

@jimmont

please update or expand the localization docs to help those (manually) creating templates for runtime localization that show how to use interpolation and what does and doesn't work, for example a template such as atemplate: (args)=>html'some text ${ args.named } does not appear to work and it's unclear if the indexed approach shown below is the only option available

thanks very much.

// templates has key with the template:
  check_email: html`checking ${ 0 }`, 
  ...
  check_email_does_not_work: (args)=>html`checking ${ args.address }`
// unclear how to make the above templates work, except for the index approach 0, 1... 
// and whether this is the only option available for logic in templates


const address = `user@host`; 
msg(str`checking...${address}`, {id:'check_email'})

// like
greeting: html`<b>Hola Mundo</b>`,
parameterized: html`<b>Hola ${0}</b>`,
htmlOrderChange: html`<b>2:${1} 1:${0}</b>`,

docs at:
https://lit.dev/docs/localization/overview/

current source of information in tests:
https://github.com/search?q=repo%3Alit%2Flit%20localize%20%7B0%7D&type=code
https://github.com/lit/lit/blob/a66737fc9b861999b00ccad01edb925172b7f711/packages/localize-tools/testdata/build-runtime-xliff/goldens/tsout/zh_CN.ts#L5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions