Closed (fixed)
Project:
Pathauto
Version:
6.x-1.x-dev
Component:
i18n Stuff
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
21 Aug 2007 at 15:29 UTC
Updated:
29 Feb 2008 at 11:43 UTC
Jump to comment: Most recent file
Creating a node with this two spanish words: Coruña and teoría
suffered with pathauto a alias like this: corun-teori
Because one image is better than thousand of bad explanations:
http://nexus7.org/corun-teori
I don't know if this combination check another language rule and that's why I obtained this.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | pathauto_transliteration_utf8_v2.patch | 732 bytes | patryk |
| #12 | pathauto_transliteration_utf8.patch | 733 bytes | patryk |
Comments
Comment #1
nexus7 commentedAnother example more interesting... I have just make some tests and with ña ñe ñi ño ñu only fails with ña...
One links more explicative...
http://nexus7.org/n-ne-ni-no-nu
Comment #2
nexus7 commentedOne thing, last stable version 5.x-1.2 works ok, this is very strange, did you change something in the php code???
Comment #3
nexus7 commentedAnother thing, if I uncheck transliterate, I get the error :( but this time with our characters, the problem is in your pathauto_cleanstring function, when you have this word "teoría" if you uncheck transliteration and you generate alias you get "teorí" where is the "a", and with "coruña" you get "coruñ" the same problem with the "a" for the moment I haven't found where you erased this "a" in your code, but I think I'm near...
Comment #4
nexus7 commentedHow I could be so stupid... It's incredible... In your code you have first this: // Get rid of words that are on the ignore list... and after this you have this: // Optionally remove accents and transliterate to a subset of ASCII-96 characters...
// Get rid of words that are on the ignore list
$ignore_re = "\b". preg_replace("/,/", "\b|\b", variable_get('pathauto_ignore_words', $ignore_words)) ."\b";
$output = preg_replace("/$ignore_re/ie", "", $output);
// Optionally remove accents and transliterate to a subset of ASCII-96 characters.
if (variable_get('pathauto_transliterate', FALSE)) {
static $i18n_loaded = false;
static $translations = array();
if (!$i18n_loaded) {
$path = drupal_get_path('module', 'pathauto');
if (is_file($path. '/i18n-ascii.txt')) {
$translations = parse_ini_file($path. '/i18n-ascii.txt');
}
$i18n_loaded = true;
}
$output = strtr($output, $translations);
But in spanish we have accents and our problem is that if you first passed the ignore list words like "teoría" loses the "a" because the accent separate this one word in two words. And after this problem the rest works perfect.
That's why you must change the position of the code, to something like:
// Optionally remove accents and transliterate to a subset of ASCII-96 characters.
if (variable_get('pathauto_transliterate', FALSE)) {
static $i18n_loaded = false;
static $translations = array();
if (!$i18n_loaded) {
$path = drupal_get_path('module', 'pathauto');
if (is_file($path. '/i18n-ascii.txt')) {
$translations = parse_ini_file($path. '/i18n-ascii.txt');
}
$i18n_loaded = true;
}
$output = strtr($output, $translations);
// Get rid of words that are on the ignore list
$ignore_re = "\b". preg_replace("/,/", "\b|\b", variable_get('pathauto_ignore_words', $ignore_words)) ."\b";
$output = preg_replace("/$ignore_re/ie", "", $output);
Comment #5
gregglesvery interesting indeed!
I didn't try to troubleshoot it because it seemed quite complex (and other issues in the queue demanded broader attention).
I think you are on the right path, but we also need a solution for people who don't want to use transliteration. If I understand this correctly, with transliteration disabled the problem will still come up as long as "a" is in the list of words to ignore.
Any ideas for how to solve that that?
Comment #6
nexus7 commentedI have explained bad sorry, my english perhaps is too bad. Now changing the order of this code works with transliteration and without transliteration. The problem was: (I'll try to explained better)
You passed first (with transliteration or without transliteration) the filter to get rid of words from ignore list. And the first word in ignore list is the "a" word, after this you remove accents from the words.
In spanish we have thousands of words with the termination "ía" for example "teoría" or perhaps with your UTF you'll see something like `teor%C3%ADa` what happens???, your code check this one word as two words separated with a strange symbol '%C3%AD', one call "teorí" and another call "a", your filter for ignore list removing the "a", after these you pass the remove accents that's why you obtain "teori" (This would be with transliteration ON)
Without transliterarion, it happens the same, first you transform "teoría" applying the ignore list in "teorí" and then you publish this because transliteration is off.
That's why the same problem happens with "Coruña" the city were I lived (we are 1000 kilometers to BCN, Barcelona :D), the filter of ignore words always treat this last "a" a separate word, filter and remove accents or make another transformation.
Now changing the order of the code works fine, first you have to remove accents and after this you have to get rid of ignore list, this is the order. I wish this would be better explained. But you can go to my test page http://nexus7.org and see that now with transliteration and without transliteration your code works because wasn't a problem at transliteration level, was an order problem in two steps that aren't interchangeable.
http://nexus7.org/en-coru%C3%B1a-hay-una-teor%C3%ADa
http://nexus7.org/coruna-teoria
As you can see I could create both with transliteration and without. I'm happy to discovered this... :D
Comment #7
gregglesI committed this change in order which is at least a partial fix.
Comment #8
nexus7 commentedThese days i can't have a look to the code, but after 10 of september I'll try to help..
Comment #9
gregglesKnown workarounds:
1) enable transliteration
2) blank out the "words to remove" section
Comment #10
gregglesmarked http://drupal.org/node/220713 as a duplicate. Also updating component.
Comment #11
patryk commentedThe same problem is with polish diacritic characters in 6.x-1.x-dev branch.
Comment #12
patryk commentedFix for "Strings to Remove", but only when mbstring module is enabled, otherwise current behaviour.
Comment #13
patryk commentedMore logical code.
Comment #14
gregglesDid the code change between #12 and #13 or just the addition of i18n-ascii.txt?
I don't want to include that file in the download for several reasons, so I think your #12 is the right one to commit, right?
Comment #15
patryk commentedPatch #13 does not have any i18n-ascii.txt included, you may need to redownload it, I have made quick swap when I noticed i18n-ascii.txt popped into patch :)
Comment #16
gregglesAh yes, now I see the difference and I agree it is more logical. In general, while you can edit comments in the issue queue and change the patch it's not a good idea (for this reason among others).
Looks great to me, will apply shortly.
Comment #17
gregglesAwesome - fixed for 5.x-2 and 6.x.
Thanks Patryk!
Comment #18
patryk commentedYou welcome! Sorry about the swap :)
Comment #19
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.