document localization template interpolation, like ${0}

未关闭
#1,404 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript

调研方向

从 https://lit.dev/docs/localization/overview/ 的本地化概览开始,并将其中关于插值的指导与 packages/localize-tools/testdata/build-runtime-xliff/goldens/tsout/zh_CN.ts 中引用的 localize-tools 测试输出进行比较。记录索引插值和命名插值的工作方式,包括示例所展示的限制,并验证由此得到的指导是否回答了是否支持其他模板逻辑这一问题。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
TypeScript
星标
140
派生
229
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lit/lit.dev 的其他 Issue

查看 lit/lit.dev 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。