# Transliteration in topic URL

**URL:** https://meta.discourse.org/t/transliteration-in-topic-url/116050
**Category:** Support
**Created:** [April 24, 2019, 3:44am UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050 "2019-04-24T03:44:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)
#### Post date: [April 24, 2019, 3:44am UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/1 "2019-04-24T03:44:52Z")

</div>

Here!

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/e/3e00cb06162ad6aa0657a41548f3f01869f4679e.png)

Some Vietnamese words with diacritics like: ă; â; ơ; ô; ả; ã convert poorly:

> Cần thuê mặt bằng 2 MT mở quán cà phê có thể ở lại giá 10tr trở về

It converts to:

> c-n-thue-m-t-b-ng-2-mt-m-quan-ca-phe-co-th-l-i-gia-10tr-tr-v/

I want it to convert to:

> can thue mat bang 2 mt mo quan ca phe co the o lai gia 10tr tro ve

On WordPress, Vietnamese topic titles convert beautifully, removing only the diacritics from the full text.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 26, 2019, 9:47am UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/2 "2019-04-26T09:47:38Z")

</div>

@gerhard any ideas?

Looks like it’s working fine when we explicitely set the locale

(_Note: `parameterize` internally calls `transliterate`_)

```ruby
> I18n.transliterate("Cần")
=> "C?n"
> I18n.transliterate("Cần", locale: "vi")
=> "Can"

```

We should probably set `I18n.locale` to the value of `SiteSetting.default_locale`?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [April 26, 2019, 10:11am UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/3 "2019-04-26T10:11:47Z")

</div>

Your default locale is set to English and the system doesn’t know how to correctly transliterate Vietnamese characters in that case. Either change the `default locale` site setting to Vietnamese or change the `slug generation method` site setting to “encoded”.

> [@Edit URL into a topic title after creation?](https://meta.discourse.org/t/edit-url-into-a-topic-title-after-creation/74932/9):
>
> Looks like it’s working fine when we explicitely set the locale

That’s exactly what’s happening in the app, but you have to do it manually in the rails console. 😉  
So, I guess the only thing we should do here is to put a `I18n.with_locale(SiteSetting.default_locale)` in `Slug.ascii_generator`, because currently it will use the user’s locale when `allow user locale` is enabled. Which is kinda weird.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 26, 2019, 10:14am UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/4 "2019-04-26T10:14:31Z")

</div>

> [@Edit URL into a topic title after creation?](https://meta.discourse.org/t/edit-url-into-a-topic-title-after-creation/74932/10):
>
> So, I guess the only thing we should do here is to put a `I18n.with_locale(SiteSetting.default_locale)` in `Slug.ascii_generator` , because currently it will use the user’s locale when `allow user locale` is enabled. Which is kinda weird.

Can you add that to your list?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [April 29, 2019, 4:31pm UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/6 "2019-04-29T16:31:46Z")

</div>

Fixed in [FIX: Generate ASCII slug with default locale · discourse/discourse@56f6065 · GitHub](https://github.com/discourse/discourse/commit/56f60653931c7aa87a8137bb2e67d093c0828fa6)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 13, 2022, 2:49pm UTC](https://meta.discourse.org/t/transliteration-in-topic-url/116050/8 "2022-08-13T14:49:00Z")

</div>


