User tests: Successful: Unsuccessful:
Add an additional filter to the alias generator to remove any apostrophe instead of replacing it with a dash. This has annoyed me forever and I waste so much time doing this manually for every alias
For example the alias for an article "Brian's Pull Request"
"brian-s-pull-request"
"brians-pull-request"
Note Includes unit test
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
because its not an allowed character. it just needs to be removed - not replaced
because its not an allowed character. it just needs to be removed - not replaced
Ah, I forgot the removal, silly me.
Labels |
Added:
?
|
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
|
as you are not using a regular expression, it would be better PHP to use str_replace (Im guessing more performant too, the tiniest bit)
Labels |
Added:
?
Removed: ? |
I have tested this item
Tested successfully in Beta8-dev of 29 March in Wampserver 3.2.4 using PHP 8.0.2.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-30 07:44:48 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
?
Removed: ? |
But it is valid only for english.
Many languages use the apostrophe with the contraction of definite articles before words (elision), so removing the dash (-) generate some problems.
IT
"L'acqua è pulita" -> "lacqua-e-pulita" (the word "lacqua" not exists).
Same for: l'uomo, l'aria, l'ora, l'eternità, l'amico, l'onestà, ecc. and all words that start with vowels.
FR
"l'eau" -> leau
"l'homme" -> lhomme
etc. Same as Italian.
Magento, Prestashop, Drupal, Typo3, and many other doesn't remove the dash for the apostrophe. Only Wordpress.
Maybe should we let the language package drive this choiche?
Then you have a definite article of just the character "l" which is also wrong as the alias would be "l-acqua"
The question is what is more wrong to a native speaker of these languages.
Evidently @simbus82 is totally right.
getting leau
instead of l-eau
just to please brians-pull-request
is very much English centered —but we have been used to that behavior for years.
We do have a solution though, @simbus82 , and it is to use unicode aliases.
There, the single quote is still using the dash and we could even make it better by replacing the single quote by a right single quote.
We could add in OutputFilter
in the method public static function stringUrlUnicodeSlug($string)
after line 162
$str = str_replace('-', ' ', $str);
the line
$str = str_replace("'", "\xE2\x80\x99", $str);
This would give from the original title
L'acqua è pulita
the alias
l’acqua-è-pulita
@brianteeman Wouldn't it be better just to add the apostrophe to the list of allowed characters in the existing
preg_replace
below the one you are adding?I.e. change
$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str);
to
$str = preg_replace('/(\s|[^A-Za-z0-9\-\'])+/', '-', $str);
instead of adding the new
preg_replace
.