If one tries to transliterate paths from entity fields (for example taxonomy) characters like ä, ü, ö are converted to a,u,o but not to ae, ue, oe. The Drupal 8 transliteration does that correctly on url-paths but for file uploads File (Field) Paths creates just a, u, o. - It would be great to have that feature for SEO and useful paths on the server.
The Problem is that the pathauto module is used to transliterate the path before File (Field) Paths does it. The code at the end of the module (/modules/filefield_paths/filefield_paths.module) should be changed in that manner:
// Transliterate string
if ($transliterate == TRUE) {
// Use the current default interface language.
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
// Instantiate the transliteration class.
$trans = \Drupal::transliteration();
// Use this to transliterate some text.
$path = $trans->transliterate($path, $langcode);
}
Moreover the Operation should be done before the path and the filename is cleared by the pathauto module:
before this
$path = \Drupal::service('pathauto.alias_cleaner')
->cleanstring($path);
if (!empty($pathinfo['extension'])) {
$path .= '.' . \Drupal::service('pathauto.alias_cleaner')
->cleanstring($pathinfo['extension']);
}
$path = str_replace('/', '', $path);
}
else {
$path = str_replace($pathinfo['filename'], \Drupal::service('pathauto.alias_cleaner')
->cleanstring($pathinfo['filename']), $path);
}
}
and before that
$path = \Drupal::service('pathauto.alias_cleaner')->cleanstring($path);
}
}
elseif ($remove_slashes) {
$path = str_replace('/', '', $path);
}
Comment | File | Size | Author |
---|---|---|---|
#5 | screenshot.png | 17.03 KB | der_manzke |
#5 | diphthongs_correct_transliteration-2750541.patch | 991 bytes | der_manzke |
Comments
Comment #2
cmsarnold CreditAttribution: cmsarnold commentedComment #3
cmsarnold CreditAttribution: cmsarnold commentedComment #4
geek-merlinHmm, might make sense - can you (learn to) roll a patch?
Comment #5
der_manzke CreditAttribution: der_manzke commentedI've hit the same problem today. I inserted the code like @cmsarnold mentioned and it works quite fine for me and translates umlauts like ä, ö and ü to ae, oe and ue.
Like you see in the screenshot it gets perfectly replaced :)
I also checked it for Japanese characters, but i don't know if it is translated well enough. (I'm not used to Japanese so i have no idea if it is correct)
This is my first patch and I'm not quite familiar with this so please check it and if it is working, feel free to use it :)
Comment #6
der_manzke CreditAttribution: der_manzke commentedI've hit the same problem today. I inserted the code like @cmsarnold mentioned and it works quite fine for me and translates umlauts like ä, ö and ü to ae, oe and ue.
Like you see in the screenshot it gets perfectly replaced :)
I also checked it for Japanese characters, but i don't know if it is translated well enough. (I'm not used to Japanese so i have no idea if it is correct)
This is my first patch and I'm not quite familiar with this so please check it and if it is working, feel free to use it :)
Comment #7
Castor-designs CreditAttribution: Castor-designs commentedThis is gold and very important. Thanks. Why is it not implemented in the official release?
Comment #8
fox mulder CreditAttribution: fox mulder commented#5 works but composer can not apply patch for 8.x-1.0-beta6
Comment #9
C-LogemannPatch needs to be relative to module folder not the complete installation path/website project as currently in #5 patch: "/web/modules/contrib/filefield_paths/"