# 本地化标签未被 slug 化

**URL:** https://meta.discourse.org/t/localized-tags-are-not-slugified/398105
**Category:** Bug
**Tags:** content-localization
**Created:** [2026年三月10日 21:32 UTC](https://meta.discourse.org/t/localized-tags-are-not-slugified/398105 "2026-03-10T21:32:25Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2026年三月12日 06:43 UTC](https://meta.discourse.org/t/localized-tags-are-not-slugified/398105/7 "2026-03-12T06:43:48Z")

</div>

我们合并了一个修复程序，用于清理从大型语言模型（LLM）返回后的本地化标签名称，同时还有一个后期迁移，用于清理现有的“脏”本地化标签名称。

> <https://github.com/discourse/discourse/pull/38488>
>
> Localized tag names were never run through \`DiscourseTagging.clean\_tag\`, unlike …regular tag names. A localized name like \`mijn-naam" (123)\` would be stored and rendered as-is, breaking body classes (\`tag-mijn-naam" (123)\`) and tag display under topic titles.
> 
> This PR adds a \`before\_validation\` callback on \`TagLocalization\` that cleans names with \`DiscourseTagging.clean\_tag\`. This covers all three entry points \`TagLocalizationCreator\`, \`TagLocalizationUpdater\`, and \`TagSettingsUpdater\` at the model.
> 
> Includes a post-migration that cleans existing dirty localization names. The migration only fetches rows that actually violate, names with special characters from \`TAGS\_FILTER\_REGEXP\`, uppercase when \`force\_lowercase\_tags\` is on, or names exceeding \`max\_tag\_length\`. The actual cleaning still uses \`DiscourseTagging.clean\_tag\` so it respects site settings. We try to minimize calling application code in migrations, but this is quite controlled.
> 
> Related: https://meta.discourse.org/t/localized-tags-are-not-slugified/398105

另外请注意，该拉取请求（PR）表明后期迁移确实有一些用于清理标签的应用程序逻辑，但在某些条件和测试下我们在这里应该是安全的。

我将保持此主题开放，以观察您的情况如何发展。

---

_[View the full topic](https://meta.discourse.org/t/localized-tags-are-not-slugified/398105)._
