Problem/Motivation
When generating URL aliases from nodes with danish characters in the title, the characters 'å' and 'ø' gets translated incorrectly to 'a' and 'o' instead of 'aa' and 'oe' using Transliteration.
In other words; the node 'På tur med øl' becomes 'pa-tur-med-ol' instead of 'paa-tur-med-oel'.
A danish translation exists in core/lib/Drupal/Component/Transliteration/data/dk.php, which is used by the PhpTransliteration class. 'dk' is not the correct langcode for Denmark. It should be 'da':
$overrides['dk'] = [
0xC5 => 'Aa',
0xD8 => 'Oe',
0xE5 => 'aa',
0xF8 => 'oe',
];
Proposed resolution
Renaming the file to da.php and changing the array key from 'dk' to 'da' fixes this issue. However, for backwards compatibility it might be better to just add a new file named 'da.php', since people might have added their own workarounds.
Correct PhpTransliterationTest.php
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#8 | core_transliteration-danish-incorrect-2895315-8-D8.patch | 1.47 KB | Krzysztof Domański |
#8 | danish-langcode.JPG | 26.35 KB | Krzysztof Domański |
#4 | add-da-transliteration-file-12171155-2.patch | 440 bytes | nielsstampe |
Comments
Comment #2
nielsstampe CreditAttribution: nielsstampe at Adapt commentedComment #3
nielsstampe CreditAttribution: nielsstampe at Adapt commentedComment #4
nielsstampe CreditAttribution: nielsstampe at Adapt commentedComment #8
Krzysztof DomańskiI confirmed that the langcode for Denmark is "da" (see attachment). Country code for Denmark is "DK" core/lib/Drupal/Core/Locale/CountryManager.php. It could have been misleading.
I think we should leave only one version, but I may be wrong. In the new patch, "dk.php" is deleted.
PhpTransliterationTest.php also needs updating:
Comment #9
Krzysztof DomańskiComment #10
borisson_I think I agree with the assesment that we should leave the wrong file behind, and use @trigger_error to mark it as deprecated. I'm not sure, so setting this to rtbc to bring this to maintainer attention.
If we don't want to do the trigger error, this looks good to go
Comment #11
Krzysztof DomańskiIf we delete the wrong "dk.php" file it will never break the transliteration, because the following code (core/lib/Drupal/Component/Transliteration/PhpTransliteration.php) checks if the file exists:
Possible solutions used so far by programmers:
1. Adding "da.php" file with patch #4 or creating a similar custom patch (probably the most common).
2. Extend class PhpTransliteration in custom module with following code:
What will happen if we remove wrong file:
In the first case, after the core update (e.g. to 8.7), Composer will inform you that the patch #4 could not be applied. It is safe.
In the second case, one or the other file will be used, so it is also safe.
That's why we probably do not have to leave a wrong file.
Comment #13
Krzysztof DomańskiI launched the re-test. It's pass.
Comment #14
borisson_Back to rtbc, with the same remarks as #10.
Comment #15
plachThis should be fixed in the dev branch first.
Comment #16
catchWe should be fine to remove the old file, it will never be found unless someone configures a custom 'dk' language, and it's data rather than an API as such. However, given that, only committing this to 8.7.x so it comes out in a minor release.
Committed 2580766 and pushed to 8.7.x. Thanks!