Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jimmont opened this issue Feb 27, 2025 · 0 comments
Open

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

jimmont opened this issue Feb 27, 2025 · 0 comments

Comments

@jimmont
Copy link

jimmont commented Feb 27, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant