Special characters on dictionary

This commit is contained in:
Diego Najar 2018-01-21 16:35:47 +01:00
parent 85290cfbb6
commit d2a7b7ff08
3 changed files with 29 additions and 2 deletions

View File

@ -6,12 +6,15 @@ class dbLanguage extends dbJSON
public $db; public $db;
public $currentLanguage; public $currentLanguage;
public $dates; public $dates;
public $specialChars;
function __construct($currentLanguage) function __construct($currentLanguage)
{ {
$this->data = array(); $this->data = array();
$this->db = array(); $this->db = array();
$this->currentLanguage = $currentLanguage; $this->currentLanguage = $currentLanguage;
$this->dates = array();
$this->specialChars = array();
// Load default language // Load default language
$filename = PATH_LANGUAGES.DEFAULT_LANGUAGE_FILE; $filename = PATH_LANGUAGES.DEFAULT_LANGUAGE_FILE;
@ -33,10 +36,18 @@ class dbLanguage extends dbJSON
unset($this->db['language-data']); unset($this->db['language-data']);
// Dates // Dates
if (isset($this->db['dates'])) {
$this->dates = $this->db['dates']; $this->dates = $this->db['dates'];
unset($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() public function locale()
{ {
if (isset($this->data['locale'])) { if (isset($this->data['locale'])) {
@ -125,4 +136,10 @@ class dbLanguage extends dbJSON
{ {
return $this->dates; return $this->dates;
} }
// Returns array with all the special characters from this language
public function getSpecialChars()
{
return $this->specialChars;
}
} }

View File

@ -128,12 +128,16 @@ class Text {
// This function can return an empty string // This function can return an empty string
public static function cleanUrl($string, $separator='-') public static function cleanUrl($string, $separator='-')
{ {
global $Language;
if (EXTREME_FRIENDLY_URL) { if (EXTREME_FRIENDLY_URL) {
$string = preg_replace("/[\/_|+ -]+/", $separator, $string); $string = preg_replace("/[\/_|+ -]+/", $separator, $string);
return $string; return $string;
} }
// Transliterate characters to ASCII // 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); $string = str_replace(array_keys(self::$specialChars), self::$specialChars, $string);
if (function_exists('iconv')) { if (function_exists('iconv')) {

View File

@ -11,6 +11,12 @@
"3": "" "3": ""
} }
}, },
"special-chars": {
"ä": "ae",
"ö": "oe",
"ü": "ue",
"ß": "ss"
},
"dates": { "dates": {
"Mon": "Mo", "Mon": "Mo",
"Tue": "Di", "Tue": "Di",