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

Comments

nexus7’s picture

Another 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

nexus7’s picture

One thing, last stable version 5.x-1.2 works ok, this is very strange, did you change something in the php code???

nexus7’s picture

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

nexus7’s picture

Title: transliteration failed with some spanish words... » transliteration failed with some spanish words... GOTCHA!!!
Status: Active » Reviewed & tested by the community

How 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);

greggles’s picture

Status: Reviewed & tested by the community » Needs work

very 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?

nexus7’s picture

I 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

greggles’s picture

I committed this change in order which is at least a partial fix.

nexus7’s picture

These days i can't have a look to the code, but after 10 of september I'll try to help..

greggles’s picture

Known workarounds:

1) enable transliteration
2) blank out the "words to remove" section

greggles’s picture

Title: transliteration failed with some spanish words... GOTCHA!!! » transliteration failed with some spanish word...
Component: Code » i18n Stuff

marked http://drupal.org/node/220713 as a duplicate. Also updating component.

patryk’s picture

The same problem is with polish diacritic characters in 6.x-1.x-dev branch.

patryk’s picture

Title: transliteration failed with some spanish word... » transliteration failed with non-latin characters
Version: 5.x-2.0-beta2 » 6.x-1.x-dev
Assigned: nexus7 » patryk
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new733 bytes

Fix for "Strings to Remove", but only when mbstring module is enabled, otherwise current behaviour.

patryk’s picture

StatusFileSize
new732 bytes

More logical code.

greggles’s picture

Status: Reviewed & tested by the community » Needs review

Did 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?

patryk’s picture

Patch #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 :)

greggles’s picture

Status: Needs review » Reviewed & tested by the community

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

greggles’s picture

Status: Reviewed & tested by the community » Fixed

Awesome - fixed for 5.x-2 and 6.x.

Thanks Patryk!

patryk’s picture

You welcome! Sorry about the swap :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.