Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Apostrophe in alias #32924

Merged
merged 4 commits into from Mar 30, 2021
Merged

[4.0] Apostrophe in alias #32924

merged 4 commits into from Mar 30, 2021

Conversation

brianteeman
Copy link
Contributor

@brianteeman brianteeman commented Mar 29, 2021

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

Example

For example the alias for an article "Brian's Pull Request"

before

"brian-s-pull-request"

after

"brians-pull-request"

Note Includes unit test

Add an additional filter to the alias generator to remove any apostrophe instead of replacing it with a dash.

### Example
For example the alias for an article "Brian's Pull Request"

### before
"brian-s-pull-request"

### after
"brians-pull-request"
@richard67
Copy link
Member

@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.

@brianteeman
Copy link
Contributor Author

because its not an allowed character. it just needs to be removed - not replaced

@richard67
Copy link
Member

because its not an allowed character. it just needs to be removed - not replaced

Ah, I forgot the removal, silly me.

@PhilETaylor

This comment was marked as abuse.

@toivo
Copy link
Contributor

toivo commented Mar 29, 2021

I have tested this item ✅ successfully on d83aacd

Tested successfully in Beta8-dev of 29 March in Wampserver 3.2.4 using PHP 8.0.2.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32924.

@alikon
Copy link
Contributor

alikon commented Mar 30, 2021

I have tested this item ✅ successfully on d83aacd


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32924.

@alikon
Copy link
Contributor

alikon commented Mar 30, 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32924.

@joomla-cms-bot joomla-cms-bot added RTC This Pull Request is Ready To Commit and removed Unit/System Tests labels Mar 30, 2021
@rdeutz rdeutz merged commit e44a1d2 into joomla:4.0-dev Mar 30, 2021
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 30, 2021
@brianteeman brianteeman deleted the alias branch March 30, 2021 09:01
@zero-24 zero-24 added this to the Joomla 4.0 milestone Mar 30, 2021
@simbus82
Copy link
Contributor

simbus82 commented Apr 2, 2021

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?

@brianteeman
Copy link
Contributor Author

Then you have a definite article of just the character "l" which is also wrong as the alias would be "l-acqua"

@richard67
Copy link
Member

The question is what is more wrong to a native speaker of these languages.

dgrammatiko pushed a commit to dgrammatiko/joomla-cms that referenced this pull request Apr 2, 2021
@infograf768
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants