WordPress.org

Ready to get started?Download WordPress

Forums

Nicer permalinks for Vietnamese
Nicer permalinks for Thai in BuddyPress (2 posts)

  1. jdawn
    Member
    Posted 3 years ago #

    I have used the Nicer Permalinks for Vietnamese code to force my BuddyPress permalinks to show in Roman characters rather than Thai characters, because BuddyPress does not allow %post_id% in its permalink structure as far as I can tell. The Thai characters which automatically appeared in the permalink on the post page were a problem for my translation plugin (Transposh). Since I have multiple Thai authors on my site, I could not be sure they would always change the peramlink to Roman characters. If they forgot, their post would result in a broken link. So I just substituted random Roman characters for Thai in this script, and wanted to share in case anyone else was having the same problem.

    Please note:
    1. This is NOT a phonetic transcription of the Thai letters; it is simply a hack to allow my BuddyPress permalinks to automatically display Roman characters because the Thai characters were confusing my translation plugin.
    2. I left the Vietnamese characters in the code.
    3. To use, simple install the Nicer Permalinks for Vietnamese plugin and copy below code over the existing code in the nicer-permalinks-for-vietnamese/np4v.php page in WordPress's plugin editor.

    Best wishes!

    <?php
    /*
    Plugin Name: Nicer permalinks for Vietnamese
    Plugin URI: http://onetruebrace.com/nicer-permalinks-for-vietnamese
    Description: A simple plugin to remove Vietnamese accents from permalinks
    Author: Quang Anh Do
    Version: 1.0
    Author URI: http://onetruebrace.com
    Modified for using Thai script in permalinks on BuddyPress: August 4, 2010
    */

    function qad_remove_accents($string) {
    $trans = array(
    'ก'=>'a','ข'=>'b','ฃ'=>'c','ฃ'=>'d','ค'=>'e','ฅ'=>'f','ฆ'=>'g','ง'=>'h','จ'=>'i','ฉ'=>'j','ช'=>'k','ซ'=>'l','ฌ'=>'m','ญ'=>'n','ฎ'=>'o',
    'ฏ'=>'p','ฐ'=>'q','ฑ'=>'r','ฒ'=>'s','ณ'=>'t','ด'=>'u','ต'=>'v','ถ'=>'w','ท'=>'x','ธ'=>'y','น'=>'z','บ'=>'aa','ป'=>'ab','ผ'=>'ac',
    'ฝ'=>'ad','พ'=>'ae','ฟ'=>'af','ภ'=>'ag','ม'=>'ah','ย'=>'ai','ร'=>'aj','ฤ'=>'ak','ล'=>'al','ฦ'=>'am','ว'=>'an','ศ'=>'ao','ษ'=>'ap','ส'=>'aq',
    'ห'=>'ar','ฬ'=>'as','อ'=>'at','ฮ'=>'au','ฯ'=>'av','ะ'=>'aw','ั'=>'ax','า'=>'ay','ำ'=>'az',
    'ิ'=>'ba','ี'=>'bb','ึ'=>'bc','ื'=>'bd','ุ'=>'be','ู'=>'bf',',ฺ'=>'bg','฿'=>'bh','เ'=>'bi','แ'=>'bj','โ'=>'bk','ใ'=>'bl','ไ'=>'bm','ๅ'=>'bn',
    'ๆ'=>'bo','็'=>'bp','่'=>'bq','้'=>'br','๊'=>'bs','๋'=>'bt','์'=>'bu','ํ'=>'bv','๎'=>'bw','๏'=>'bx','๐'=>'0','๑'=>'1','๒'=>'2','๓'=>'3','๔'=>'4',
    '๕'=>'5','๖'=>'6','๗'=>'7','๘'=>'8','๙'=>'9','๚'=>'by','๛'=>'bz',
    'à'=>'a','á'=>'a','ả'=>'a','ã'=>'a','ạ'=>'a',
    'ă'=>'a','ằ'=>'a','ắ'=>'a','ẳ'=>'a','ẵ'=>'a','ặ'=>'a',
    'â'=>'a','ầ'=>'a','ấ'=>'a','ẩ'=>'a','ẫ'=>'a','ậ'=>'a',
    'À'=>'a','Á'=>'a','Ả'=>'a','Ã'=>'a','Ạ'=>'a',
    'Ă'=>'a','Ằ'=>'a','Ắ'=>'a','Ẳ'=>'a','Ẵ'=>'a','Ặ'=>'a',
    'Â'=>'a','Ầ'=>'a','Ấ'=>'a','Ẩ'=>'a','Ẫ'=>'a','Ậ'=>'a',
    'đ'=>'d','Đ'=>'d',
    'è'=>'e','é'=>'e','ẻ'=>'e','ẽ'=>'e','ẹ'=>'e',
    'ê'=>'e','ề'=>'e','ế'=>'e','ể'=>'e','ễ'=>'e','ệ'=>'e',
    'È'=>'e','É'=>'e','Ẻ'=>'e','Ẽ'=>'e','Ẹ'=>'e',
    'Ê'=>'e','Ề'=>'e','Ế'=>'e','Ể'=>'e','Ễ'=>'e','Ệ'=>'e',
    'ì'=>'i','í'=>'i','ỉ'=>'i','ĩ'=>'i','ị'=>'i',
    'Ì'=>'i','Í'=>'i','Ỉ'=>'i','Ĩ'=>'i','Ị'=>'i',
    'ò'=>'o','ó'=>'o','ỏ'=>'o','õ'=>'o','ọ'=>'o',
    'ô'=>'o','ồ'=>'o','ố'=>'o','ổ'=>'o','ỗ'=>'o','ộ'=>'o',
    'ơ'=>'o','ờ'=>'o','ớ'=>'o','ở'=>'o','ỡ'=>'o','ợ'=>'o',
    'Ò'=>'o','Ó'=>'o','Ỏ'=>'o','Õ'=>'o','Ọ'=>'o',
    'Ô'=>'o','Ồ'=>'o','Ố'=>'o','Ổ'=>'o','Ỗ'=>'o','Ộ'=>'o',
    'Ơ'=>'o','Ờ'=>'o','Ớ'=>'o','Ở'=>'o','Ỡ'=>'o','Ợ'=>'o',
    'ù'=>'u','ú'=>'u','ủ'=>'u','ũ'=>'u','ụ'=>'u',
    'ư'=>'u','ừ'=>'u','ứ'=>'u','ử'=>'u','ữ'=>'u','ự'=>'u',
    'Ù'=>'u','Ú'=>'u','Ủ'=>'u','Ũ'=>'u','Ụ'=>'u',
    'Ư'=>'u','Ừ'=>'u','Ứ'=>'u','Ử'=>'u','Ữ'=>'u','Ự'=>'u',
    'ỳ'=>'y','ý'=>'y','ỷ'=>'y','ỹ'=>'y','ỵ'=>'y',
    'Y'=>'y','Ỳ'=>'y','Ý'=>'y','Ỷ'=>'y','Ỹ'=>'y','Ỵ'=>'y'
    );
    return strtr($string, $trans);
    }

    add_filter('sanitize_title', 'qad_remove_accents', 1);

    ?>

    http://wordpress.org/extend/plugins/nicer-permalinks-for-vietnamese/

  2. whateverfree
    Member
    Posted 3 years ago #

    Hi,

    But it doen't work when I posted from Windows Live Writer .

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic