is there helper class available codeigniter translate german characters pass thme in url?
for example
ä = ae, ü = ue, ß=ss, ö=oe
thanks in advance.
pyrocms has basic character conversion improved upon:
if ( ! function_exists('url_title')) { function url_title($str, $separator = 'dash', $lowercase = false) { $ci =& get_instance(); $foreign_characters = array( '/ä|æ|ǽ/' => 'ae', '/ö|œ/' => 'oe', '/ü/' => 'ue', '/Ä/' => 'ae', '/Ü/' => 'ue', '/Ö/' => 'oe', '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|А/' => 'a', '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|а/' => 'a', '/Б/' => 'b', '/б/' => 'b', '/Ç|Ć|Ĉ|Ċ|Č|Ц/' => 'c', '/ç|ć|ĉ|ċ|č|ц/' => 'c', '/Ð|Ď|Đ|Д/' => 'd', '/ð|ď|đ|д/' => 'd', '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Е|Ё|Э/' => 'e', '/è|é|ê|ë|ē|ĕ|ė|ę|ě|е|ё|э/' => 'e', '/Ф/' => 'f', '/ф/' => 'f', '/Ĝ|Ğ|Ġ|Ģ|Г/' => 'g', '/ĝ|ğ|ġ|ģ|г/' => 'g', '/Ĥ|Ħ|Х/' => 'h', '/ĥ|ħ|х/' => 'h', '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|И/' => 'i', '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и/' => 'i', '/Ĵ|Й/' => 'j', '/ĵ|й/' => 'j', '/Ķ|К/' => 'k', '/ķ|к/' => 'k', '/Ĺ|Ļ|Ľ|Ŀ|Ł|Л/' => 'l', '/ĺ|ļ|ľ|ŀ|ł|л/' => 'l', '/М/' => 'm', '/м/' => 'm', '/Ñ|Ń|Ņ|Ň|Н/' => 'n', '/ñ|ń|ņ|ň|ʼn|н/' => 'n', '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|О/' => 'o', '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|о/' => 'o', '/П/' => 'p', '/п/' => 'p', '/Ŕ|Ŗ|Ř|Р/' => 'r', '/ŕ|ŗ|ř|р/' => 'r', '/Ś|Ŝ|Ş|Š|С/' => 's', '/ś|ŝ|ş|š|ſ|с/' => 's', '/Ţ|Ť|Ŧ|Т/' => 't', '/ţ|ť|ŧ|т/' => 't', '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|У/' => 'u', '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|у/' => 'u', '/В/' => 'v', '/в/' => 'v', '/Ý|Ÿ|Ŷ|Ы/' => 'y', '/ý|ÿ|ŷ|ы/' => 'y', '/Ŵ/' => 'w', '/ŵ/' => 'w', '/Ź|Ż|Ž|З/' => 'z', '/ź|ż|ž|з/' => 'z', '/Æ|Ǽ/' => 'ae', '/ß/'=> 'ss', '/IJ/' => 'ij', '/ij/' => 'ij', '/Œ/' => 'oe', '/ƒ/' => 'f', '/Ч/' => 'ch', '/ч/' => 'ch', '/Ю/' => 'ju', '/ю/' => 'ju', '/Я/' => 'ja', '/я/' => 'ja', '/Ш/' => 'sh', '/ш/' => 'sh', '/Щ/' => 'shch', '/щ/' => 'shch', '/Ж/' => 'zh', '/ж/' => 'zh', ); $str = preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); $replace = ($separator == 'dash') ? '-' : '_'; $trans = array( '&\#\d+?;' => '', '&\s+?;' => '', '\s+' => $replace, '[^a-z0-9\-\._]' => '', $replace.'+' => $replace, $replace.'$' => $replace, '^'.$replace => $replace, '\.+$' => '' ); $str = strip_tags($str); foreach ($trans $key => $val) { $str = preg_replace("#".$key."#i", $val, $str); } if ($lowercase === true) { if( function_exists('mb_convert_case') ) { $str = mb_convert_case($str, mb_case_lower, "utf-8"); } else { $str = strtolower($str); } } $str = preg_replace('#[^'.$ci->config->item('permitted_uri_chars').']#i', '', $str); return trim(stripslashes($str)); } }
Comments
Post a Comment