# 在开发过程中无法看到 i18n 字符串

**URL:** https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909
**Category:** Development
**Created:** [2024年八月22日 15:18 UTC](https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909 "2024-08-22T15:18:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2024年八月22日 15:18 UTC](https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909/1 "2024-08-22T15:18:01Z")

</div>

当我开始开发新插件时，我的开发环境无法识别属于新插件的 `client.en.yml` 字符串。它确实可以识别所有其他 i18n 字符串，包括核心和其他插件的。

以前在引入新的 `client.en.yml` 文件时也遇到过这个问题，之后过几个小时或者在我做了某些操作（如果我知道是什么的话）之后问题就消失了。当问题消失时，它会毫无问题地识别 i18n 字符串的更新。就好像需要一些时间（或某个操作）才能识别该文件。

### `config/locales/client.en.yml`

```yaml
en:
  js:
    my_plugin:
      description_placeholder: "Enter description"

```

### `hbs` 文件：

```html
    <Input
      type="text"
      ...
      placeholder={{i18n "my_plugin.description_placeholder"}}
    />

```

### 浏览器显示：

`[en.my_plugin.description_placeholder]`

### 管理员 - 自定义 - 文本：

显示正确的字符串（！！！！），键为 `js.my_plugin.description_placeholder`

当我更改管理员 - 自定义 - 文本中的字符串时，浏览器会显示修改。  
当我恢复更改的字符串时，浏览器会回到 `[en.my_plugin.description_placeholder]`

我已经重启了 bin/ember-cli  
我已经重启了 rails

当我修改文件时，ember-cli 会注意到并输出 `file changed client.en.yml`

有人遇到过这种情况吗？

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2024年八月22日 19:50 UTC](https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909/2 "2024-08-22T19:50:41Z")

</div>

刚才，重启解决了这个问题……

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2024年十月29日 13:08 UTC](https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909/3 "2024-10-29T13:08:38Z")

</div>

这应该能解决问题：

> <https://github.com/discourse/discourse/pull/29468>
>
> Our sprockets-based locale pipeline correctly \`depends\_on\` client.\*.yml files wh…ich already exist. But sprockets does not provide a way to watch for the creation of new files matching a certain path. This commit works around that limitation by adding the set of client.\*.yml files to our global cache-clearing logic

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2024年十一月11日 08:00 UTC](https://meta.discourse.org/t/unable-to-see-i18n-strings-during-development/322909/4 "2024-11-11T08:00:36Z")

</div>

此主题已在 12 天后自动关闭。不再允许回复。
