Vietnamese slug support for better SEO


(Khoa Nguyen) #1

My Discourse is in Vietnamese. And with the default slug of Discourse, the URL looks urgly.
Can you add support for Vietnamese slug?


(Kane York) #2

Do you want an English transliteration of the topic title? I think that’s available @sam ?


(Khoa Nguyen) #3

Vietnamese have about 7-8 special characters. I think change them to English first and then use the current slug function.
I contributed to this github repository
https:// Vietnamese support · Issue #43 · cocur/slugify · GitHub


(Sam Saffron) #4

We use stringex for Chinese (and not Korean cause in Korean it looks like a bug)

If you add Vietnamese there does it work?


(Khoa Nguyen) #5

I don’t know about ruby or rails. But I think I’ll work. Just need to replace some character before run the slug function. Can you show me where I can edit it? I’ll try.


(Sam Saffron) #7

Do you have a dev environment, just do gem install stringex and run it through irb


(Khoa Nguyen) #8

Thanks. I’ll try it.


(Khoa Nguyen) #9

Sorry but I’m a noob in Ruby.
But I write this list (PHP), can you implement it in the next update ?

The left column is character need to be replaced and the right column is the replace character
I tried with slug.gsub("ạ", "a") and it worked.
Please note that the Vietnamese translations of Discourse is completed < 40% so I can’t set vi_VN into default locate.

        'ạ' => 'a',
        'ả' => 'a',
        'ầ' => 'a',
        'ấ' => 'a',
        'ậ' => 'a',
        'ẩ' => 'a',
        'ẫ' => 'a',
        'ằ' => 'a',
        'ắ' => 'a',
        'ặ' => 'a',
        'ẳ' => 'a',
        'ẵ' => 'a',
        'ẹ' => 'e',
        'ẻ' => 'e',
        'ẽ' => 'e',
        'ề' => 'e',
        'ế' => 'e',
        'ệ' => 'e',
        'ể' => 'e',
        'ễ' => 'e',
        'ị' => 'i',
        'ỉ' => 'i',
        'ọ' => 'o',
        'ỏ' => 'o',
        'ồ' => 'o',
        'ố' => 'o',
        'ộ' => 'o',
        'ổ' => 'o',
        'ỗ' => 'o',
        'ờ' => 'o',
        'ớ' => 'o',
        'ợ' => 'o',
        'ở' => 'o',
        'ỡ' => 'o',
        'ụ' => 'u',
        'ủ' => 'u',
        'ừ' => 'u',
        'ứ' => 'u',
        'ự' => 'u',
        'ử' => 'u',
        'ữ' => 'u',
        'ỳ' => 'y',
        'ỵ' => 'y',
        'ỷ' => 'y',
        'ỹ' => 'y',
        'Ạ' => 'A',
        'Ả' => 'A',
        'Ầ' => 'A',
        'Ấ' => 'A',
        'Ậ' => 'A',
        'Ẩ' => 'A',
        'Ẫ' => 'A',
        'Ằ' => 'A',
        'Ắ' => 'A',
        'Ặ' => 'A',
        'Ẳ' => 'A',
        'Ẵ' => 'A',
        'Ẹ' => 'E',
        'Ẻ' => 'E',
        'Ẽ' => 'E',
        'Ề' => 'E',
        'Ế' => 'E',
        'Ệ' => 'E',
        'Ể' => 'E',
        'Ễ' => 'E',
        'Ị' => 'I',
        'Ỉ' => 'I',
        'Ọ' => 'O',
        'Ỏ' => 'O',
        'Ồ' => 'O',
        'Ố' => 'O',
        'Ộ' => 'O',
        'Ổ' => 'O',
        'Ỗ' => 'O',
        'Ờ' => 'O',
        'Ớ' => 'O',
        'Ợ' => 'O',
        'Ở' => 'O',
        'Ỡ' => 'O',
        'Ụ' => 'U',
        'Ủ' => 'U',
        'Ừ' => 'U',
        'Ứ' => 'U',
        'Ự' => 'U',
        'Ử' => 'U',
        'Ữ' => 'U',
        'Ỳ' => 'Y',
        'Ỵ' => 'Y',
        'Ỷ' => 'Y',
        'Ỹ' => 'Y',

(Sam Saffron) #10

I strongly recommend first addressing that problem by translating before tackling slugs.


(Khoa Nguyen) #11

@sam this is my final solution for this feature
https://github.com/discourse/discourse/pull/3013

Is there any rake task I can run to update all current slugs ?
To update a slug, I have to change the topic title to something new and then restore the topic tilte due to this error


Mods/admins to change topic URL slug (just like in WordPress)
(Kane York) #12

@thangngoc89 can you contribute your Vietnamese translations to Discourse proper so that you can carry less patches on your forum?


(Khoa Nguyen) #13

I’m sorry. I’m very busy right now but I will translate Discourse to Vietnamese when I have free time. And I don’t see how slug and translation are related?


(Kane York) #14

Ah, because we’re consolidating the transliterations based on the forum locale:


(Khoa Nguyen) #15

I see. I’ll try my best.
Cc @trandatnh


(Lê Trần Đạt) #16

Do I need to use the vietnamese slug plug in anymore?


(Gerhard Schlager) #17

It should now work out of the box.


(Khoa Nguyen) #18

No, you still need it because that commit only work if your Discourse instance is using vi as default language.
@gerhard yes it will, but Vietnamese translation is only about 40% complete. That’s the problem


(Lê Trần Đạt) #19

I’m not going to use vi as default language, let stick with your plugin for awhile :slight_smile:


(Khoa Nguyen) #20

But I hope I can remove that plugin from my instance :smiley:


(Lê Trần Đạt) #21

Can you improve this plugin to help in translating unicode characters when new users create account from there Facebook or Google Plus, …?

I often see a number of peole having strange name such as

  • @L_Tr_n_D_t
  • Ti_u_C_ng

since the original unicode characters have been replaced by _