# Unexpected language code

**URL:** https://meta.discourse.org/t/unerwarteter-sprachcode/402544
**Category:** Bug
**Tags:** translation, fixed, content-localization
**Created:** [May 9, 2026, 5:23am UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544 "2026-05-09T05:23:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![asa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/asa/32/184869_2.png) [@asa](https://meta.discourse.org/u/asa)
#### Post date: [May 9, 2026, 5:23am UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544/1 "2026-05-09T05:23:37Z")

</div>

I ran a Google Pagespeed test on my instance and received the following message:

 ![Screenshot 2026-05-09 at 6:24:38 AM](https://global.discourse-cdn.com/meta/original/4X/a/0/9/a09ed6bc343c3d11a9d71d737c0c61a518fbf8ac.png)

I can’t explain what’s causing it. Is there an error in the translator?

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [May 9, 2026, 3:05pm UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544/3 "2026-05-09T15:05:31Z")

</div>

I think the invalid code comes from Discourse.

> <https://github.com/discourse/discourse/blob/0ae63cf570518910042eb864c2acc7ef8e8374a5/app/views/common/_hreflang_tags.html.erb#L8>

Maybe instead of `hreflang="<%= locale %>"` it should be `hreflang="<%= locale.tr('_', '-') %>"` to replace the underscore.

---

<div class="post-metadata">

### Author: ![asa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/asa/32/184869_2.png) [@asa](https://meta.discourse.org/u/asa)
#### Post date: [May 11, 2026, 12:43pm UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544/5 "2026-05-11T12:43:14Z")

</div>

I have submitted a Pull Request to fix this in the Discourse repository:

[https://github.com/discourse/discourse/pull/39884](https://github.com/discourse/discourse/pull/39884)

This change ensures the `hreflang` attribute is SEO-compliant while keeping the internal locale parameters functional.

---

<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: [May 19, 2026, 1:19pm UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544/6 "2026-05-19T13:19:07Z")

</div>

Thank you for your PR, I’ve added specs and merged it.

---

<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: [May 22, 2026, 1:19pm UTC](https://meta.discourse.org/t/unerwarteter-sprachcode/402544/7 "2026-05-22T13:19:36Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
