• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
url_title and apostrophe

#1
I noticed that the url_title fonction does not convert apostrophes (single quotes) to dash (or underscore).

French apostrophe is the same character as single quote.
For example : "L'apostrophe" should be slugifyed as "l-apostrophe"
Currently, single quotes are removed and not converted to separators (L'apostrophe  lapostrophe).

I would like to update the url_title function, but I'm not familiar with regex. Could someone help me to update the function so that it converts single quotes into dash.

PHP Code:
// url_helper.php - line 493
$trans = array(
 
'&.+?;' => '',
'[^\w\d _-]' => '',
'\s+' => $separator,
'('.$q_separator.')+' => $separator
); 
Reply

#2
URL Helper ain't an expert on foreign characters, but convert_accented_characters() are.
url_title(convert_accented_characters('L'apostrophe'));

https://www.codeigniter.com/user_guide/h...characters

Can't seem to find it, so you need to add it in your application/config/foreign_chars.php
'/L\'/' => 'L-',
Reply

#3
(11-02-2018, 12:10 AM)jreklund Wrote: URL Helper ain't an expert on foreign characters, but convert_accented_characters() are.
url_title(convert_accented_characters('L'apostrophe'));

https://www.codeigniter.com/user_guide/h...characters

Can't seem to find it, so you need to add it in your application/config/foreign_chars.php
'/L\'/' => 'L-',

That's interesting. The problem is that, in French, apostrophe can be associated to many characters, for example :
  • Aujourd'hui
  • D'avantage
  • L'amérique
  • N'ai-je donc 
  • Ch'ti
Not sure this is a good idea to add the following line in foreign_chars.php

PHP Code:
'/\'/' => ' '
What do you think ?
Reply

#4
No, not really.

I would make a function like this:
PHP Code:
function french_url_title($str,$seperator='-',$lowercase=FALSE) {
    
url_title(str_replace("'",'-',$str),$seperator,$lowercase);

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.