Transliteration in topic URL

Here!

Some word Vietnamese sign will convert ugly when have sign: ă; â; ơ; ô; ả; ã

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

will convert to

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

i wanna convert to

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

On wordpress, title topic vietnamese convert beauty, full text only removed sign

3 Likes

@gerhard any ideas?

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

(Note: parameterize internally calls transliterate)

> 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?

1 Like

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”.

That’s exactly what’s happening in the app, but you have to do it manually in the rails console. :wink:
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.

6 Likes

Can you add that to your list?

1 Like

Fixed in FIX: Generate ASCII slug with default locale · discourse/discourse@56f6065 · GitHub

4 Likes