Problem/Motivation
I have an issue that has been brought up several times on this queue, but I wanted to more thoroughly explain the problem/conflicts and get feedback about how the maintainers suggest to address this issue.
Our URL alias is using the [node:title] placeholder. We would like to remove ® from our URL, because currently node with title 'My product ®' becomes something like '/node/my-productr'. The reason this is happening (with default settings) is that transliteration runs first, and converts ® to (R). Then punctuation runs and removes the parenthesis, and eventually casts to lowercase thus we are left with 'r'.
AFAICS, simply adding ® to punctuation rules via hook_pathauto_punctuation_chars_alter (as suggested in this drupal 7 issue) isn't enough - in this case transliteration STILL runs first, and by the time it gets to punctuation it will be reduced to (R) already.
Another issue proposes running punctuation first, before transliteration. This works, but then causes new problems - for example when transliteration replaces unknown characters with other strings that we want punctuation to clean up, such as the parenthesis from ®, then they will still be in the URL. My guess is that this patch is probably not desired by the module due to its extra duty of cleaning up after transliteration.
Which leaves me with the following question: what is the recommendation to remove ®? We want to keep transliteration on to handle foreign language characters, but looking at the code there's seems to be no way to do both of these things at once.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | registered-sign-patch-3032769.patch | 925 bytes | bohus ulrych |
Comments
Comment #2
duaelfrI think that #2979476: Remove the punctuation before transliteration fixes the issue without side effects. To use your example, your "®" should be entirely removed or replaced by the separator ("-" by default) so there would be no extra parenthesis to clean before transliteration.
Comment #3
bohus ulrychHi,
I have same issue - ® is not removed from URL alias.
I'm not using "Transliterate prior to creating alias" neither "Reduce strings to letters and numbers"
If I put ® into box for "Strings to Remove" - nothing happen.
I've created custom patch to put ® to the $punctuation list in the getPunctuationCharacters().
I'm using pathauto 8.x-1.8 and Drupal 9.1.0. Don't forget to rebuild cache after applying patch.
Comment #4
phonoman commentedSeems like
hook_pathauto_punctuation_chars_alternow does a clear once before and after transliteration - change introduced in the very same issue referred here https://www.drupal.org/project/pathauto/issues/2979476I'll also close this since this is doable with the punctuation hook, even though I'm a bit puzzled why those symbols aren't included in pathauto settings by default.
Comment #5
karimb commented#4 works like a charm with Drupal core 9.3.9
Thank you @Phonoman!
Comment #6
szato commentedThank you, I'm using #4 too, extended with: