Danish letters; Ø and Å are not "slugified" correctly

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
fabelmik
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon Feb 06, 2012 12:39 pm

Danish letters; Ø and Å are not "slugified" correctly

Post by fabelmik » Tue Mar 20, 2018 5:37 pm

Hi,

I´ve been working with Joomla for some time now, and something has bothered from the beginning.

The Danish characters Ø and Å are not being slugified correctly by Joomla with JFilterOutput::stringURLSafe()

As it is in current version of Joomla the characters are converted like this:

Ø / ø => o
Å / å => a

To my knowledge the correct conversion is like this:

Ø / ø => oe
Å / å => aa

Who do I need to contact in order to correct this issue?

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24986
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Danish letters; Ø and Å are not "slugified" correctly

Post by pe7er » Tue Mar 20, 2018 5:52 pm

Have you have tested this issue on a Joomla 3.8.6 website?
And on different servers? (to make sure it's not server related)
And a recent PHP7 version?

If you can reproduce the issue on different servers (with a recent PHP version) with the latest Joomla version,
then you could create an issue for it at github:
https://github.com/joomla/joomla-cms/issues
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

fabelmik
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon Feb 06, 2012 12:39 pm

Re: Danish letters; Ø and Å are not "slugified" correctly

Post by fabelmik » Tue Mar 20, 2018 6:29 pm

pe7er wrote:Have you have tested this issue on a Joomla 3.8.6 website?
And on different servers? (to make sure it's not server related)
And a recent PHP7 version?
Yes, I have seen this behavior on all the Joomla sites I´ve worked on, also with the latest Joomla version.
i will do as you say and submit the issue on github

User avatar
Kubik-Rubik
Joomla! Explorer
Joomla! Explorer
Posts: 269
Joined: Wed Aug 25, 2010 1:59 pm
Location: Karlsruhe - Germany
Contact:

Re: Danish letters; Ø and Å are not "slugified" correctly

Post by Kubik-Rubik » Tue Mar 20, 2018 9:02 pm

Hi fabelmik,

you can either fix it globally in the Joomla! framework or locally in the Danish language file.

1. Global fix:

Create a pull request with the change ('ø' => 'oe', 'Ø' => 'Oe' and so on) in libraries/src/Language/Transliterate.php.

2. Local fix

Add the following code within the class da_DKLocalise into the file language/da-DK/da-DK.localise.php

Code: Select all

public static function transliterate($string)
{
	$string = static::utf8_latin_to_ascii($string);
	$string = utf8_strtolower($string);

	return $string;
}

private static function utf8_latin_to_ascii($string, $case = 0)
{
	static $UTF8_LOWER_ACCENTS = null;
	static $UTF8_UPPER_ACCENTS = null;

	if ($case <= 0)
	{
		if (is_null($UTF8_LOWER_ACCENTS))
		{
			$UTF8_LOWER_ACCENTS = array(
				'à' => 'a',
				'ô' => 'o',
				'ď' => 'd',
				'ḟ' => 'f',
				'ë' => 'e',
				'š' => 's',
				'ơ' => 'o',
				'ß' => 'ss',
				'ă' => 'a',
				'ř' => 'r',
				'ț' => 't',
				'ň' => 'n',
				'ā' => 'a',
				'ķ' => 'k',
				'ŝ' => 's',
				'ỳ' => 'y',
				'ņ' => 'n',
				'ĺ' => 'l',
				'ħ' => 'h',
				'ṗ' => 'p',
				'ó' => 'o',
				'ú' => 'u',
				'ě' => 'e',
				'é' => 'e',
				'ç' => 'c',
				'ẁ' => 'w',
				'ċ' => 'c',
				'õ' => 'o',
				'ṡ' => 's',
				'ø' => 'oe',
				'ģ' => 'g',
				'ŧ' => 't',
				'ș' => 's',
				'ė' => 'e',
				'ĉ' => 'c',
				'ś' => 's',
				'î' => 'i',
				'ű' => 'u',
				'ć' => 'c',
				'ę' => 'e',
				'ŵ' => 'w',
				'ṫ' => 't',
				'ū' => 'u',
				'č' => 'c',
				'ö' => 'oe',
				'è' => 'e',
				'ŷ' => 'y',
				'ą' => 'a',
				'ł' => 'l',
				'ų' => 'u',
				'ů' => 'u',
				'ş' => 's',
				'ğ' => 'g',
				'ļ' => 'l',
				'ƒ' => 'f',
				'ž' => 'z',
				'ẃ' => 'w',
				'ḃ' => 'b',
				'å' => 'aa',
				'ì' => 'i',
				'ï' => 'i',
				'ḋ' => 'd',
				'ť' => 't',
				'ŗ' => 'r',
				'ä' => 'ae',
				'í' => 'i',
				'ŕ' => 'r',
				'ê' => 'e',
				'ü' => 'ue',
				'ò' => 'o',
				'ē' => 'e',
				'ñ' => 'n',
				'ń' => 'n',
				'ĥ' => 'h',
				'ĝ' => 'g',
				'đ' => 'd',
				'ĵ' => 'j',
				'ÿ' => 'y',
				'ũ' => 'u',
				'ŭ' => 'u',
				'ư' => 'u',
				'ţ' => 't',
				'ý' => 'y',
				'ő' => 'o',
				'â' => 'a',
				'ľ' => 'l',
				'ẅ' => 'w',
				'ż' => 'z',
				'ī' => 'i',
				'ã' => 'a',
				'ġ' => 'g',
				'ṁ' => 'm',
				'ō' => 'o',
				'ĩ' => 'i',
				'ù' => 'u',
				'į' => 'i',
				'ź' => 'z',
				'á' => 'a',
				'û' => 'u',
				'þ' => 'th',
				'ð' => 'dh',
				'æ' => 'ae',
				'µ' => 'u',
				'ĕ' => 'e',
				'œ' => 'oe',
			);
		}

		$string = str_replace(array_keys($UTF8_LOWER_ACCENTS), array_values($UTF8_LOWER_ACCENTS), $string);
	}

	if ($case >= 0)
	{
		if (is_null($UTF8_UPPER_ACCENTS))
		{
			$UTF8_UPPER_ACCENTS = array(
				'À' => 'A',
				'Ô' => 'O',
				'Ď' => 'D',
				'Ḟ' => 'F',
				'Ë' => 'E',
				'Š' => 'S',
				'Ơ' => 'O',
				'Ă' => 'A',
				'Ř' => 'R',
				'Ț' => 'T',
				'Ň' => 'N',
				'Ā' => 'A',
				'Ķ' => 'K',
				'Ŝ' => 'S',
				'Ỳ' => 'Y',
				'Ņ' => 'N',
				'Ĺ' => 'L',
				'Ħ' => 'H',
				'Ṗ' => 'P',
				'Ó' => 'O',
				'Ú' => 'U',
				'Ě' => 'E',
				'É' => 'E',
				'Ç' => 'C',
				'Ẁ' => 'W',
				'Ċ' => 'C',
				'Õ' => 'O',
				'Ṡ' => 'S',
				'Ø' => 'Oe',
				'Ģ' => 'G',
				'Ŧ' => 'T',
				'Ș' => 'S',
				'Ė' => 'E',
				'Ĉ' => 'C',
				'Ś' => 'S',
				'Î' => 'I',
				'Ű' => 'U',
				'Ć' => 'C',
				'Ę' => 'E',
				'Ŵ' => 'W',
				'Ṫ' => 'T',
				'Ū' => 'U',
				'Č' => 'C',
				'Ö' => 'Oe',
				'È' => 'E',
				'Ŷ' => 'Y',
				'Ą' => 'A',
				'Ł' => 'L',
				'Ų' => 'U',
				'Ů' => 'U',
				'Ş' => 'S',
				'Ğ' => 'G',
				'Ļ' => 'L',
				'Ƒ' => 'F',
				'Ž' => 'Z',
				'Ẃ' => 'W',
				'Ḃ' => 'B',
				'Å' => 'Aa',
				'Ì' => 'I',
				'Ï' => 'I',
				'Ḋ' => 'D',
				'Ť' => 'T',
				'Ŗ' => 'R',
				'Ä' => 'Ae',
				'Í' => 'I',
				'Ŕ' => 'R',
				'Ê' => 'E',
				'Ü' => 'Ue',
				'Ò' => 'O',
				'Ē' => 'E',
				'Ñ' => 'N',
				'Ń' => 'N',
				'Ĥ' => 'H',
				'Ĝ' => 'G',
				'Đ' => 'D',
				'Ĵ' => 'J',
				'Ÿ' => 'Y',
				'Ũ' => 'U',
				'Ŭ' => 'U',
				'Ư' => 'U',
				'Ţ' => 'T',
				'Ý' => 'Y',
				'Ő' => 'O',
				'Â' => 'A',
				'Ľ' => 'L',
				'Ẅ' => 'W',
				'Ż' => 'Z',
				'Ī' => 'I',
				'Ã' => 'A',
				'Ġ' => 'G',
				'Ṁ' => 'M',
				'Ō' => 'O',
				'Ĩ' => 'I',
				'Ù' => 'U',
				'Į' => 'I',
				'Ź' => 'Z',
				'Á' => 'A',
				'Û' => 'U',
				'Þ' => 'Th',
				'Ð' => 'Dh',
				'Æ' => 'Ae',
				'Ĕ' => 'E',
				'Œ' => 'Oe',
			);
		}

		$string = str_replace(array_keys($UTF8_UPPER_ACCENTS), array_values($UTF8_UPPER_ACCENTS), $string);
	}

	return $string;
}
Have success!
Cheers
Viktor

Kubik-Rubik Joomla! Extensions https://kubik-rubik.de
Former member of Joomla! Production Leadership Team, Security Strike Team and Bug Squash Team


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”