From d2a7b7ff08fc8f5c2366175f2cf7931359626c12 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Sun, 21 Jan 2018 16:35:47 +0100 Subject: [PATCH] Special characters on dictionary --- bl-kernel/dblanguage.class.php | 21 +++++++++++++++++++-- bl-kernel/helpers/text.class.php | 4 ++++ bl-languages/de_DE.json | 6 ++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/bl-kernel/dblanguage.class.php b/bl-kernel/dblanguage.class.php index e1bbcca0..3bf64d58 100644 --- a/bl-kernel/dblanguage.class.php +++ b/bl-kernel/dblanguage.class.php @@ -6,12 +6,15 @@ class dbLanguage extends dbJSON public $db; public $currentLanguage; public $dates; + public $specialChars; function __construct($currentLanguage) { $this->data = array(); $this->db = array(); $this->currentLanguage = $currentLanguage; + $this->dates = array(); + $this->specialChars = array(); // Load default language $filename = PATH_LANGUAGES.DEFAULT_LANGUAGE_FILE; @@ -33,8 +36,16 @@ class dbLanguage extends dbJSON unset($this->db['language-data']); // Dates - $this->dates = $this->db['dates']; - unset($this->db['dates']); + if (isset($this->db['dates'])) { + $this->dates = $this->db['dates']; + unset($this->db['dates']); + } + + // Special chars + if (isset($this->db['special-chars'])) { + $this->specialChars = $this->db['special-chars']; + unset($this->db['special-chars']); + } } public function locale() @@ -125,4 +136,10 @@ class dbLanguage extends dbJSON { return $this->dates; } + + // Returns array with all the special characters from this language + public function getSpecialChars() + { + return $this->specialChars; + } } \ No newline at end of file diff --git a/bl-kernel/helpers/text.class.php b/bl-kernel/helpers/text.class.php index f6ea1df5..e72cdbc6 100644 --- a/bl-kernel/helpers/text.class.php +++ b/bl-kernel/helpers/text.class.php @@ -128,12 +128,16 @@ class Text { // This function can return an empty string public static function cleanUrl($string, $separator='-') { + global $Language; + if (EXTREME_FRIENDLY_URL) { $string = preg_replace("/[\/_|+ -]+/", $separator, $string); return $string; } // Transliterate characters to ASCII + $specialCharsFromDictionary = $Language->getSpecialChars(); + $string = str_replace(array_keys($specialCharsFromDictionary), $specialCharsFromDictionary, $string); $string = str_replace(array_keys(self::$specialChars), self::$specialChars, $string); if (function_exists('iconv')) { diff --git a/bl-languages/de_DE.json b/bl-languages/de_DE.json index d29cf3cb..3ac83774 100644 --- a/bl-languages/de_DE.json +++ b/bl-languages/de_DE.json @@ -11,6 +11,12 @@ "3": "" } }, + "special-chars": { + "ä": "ae", + "ö": "oe", + "ü": "ue", + "ß": "ss" + }, "dates": { "Mon": "Mo", "Tue": "Di",