Skip to content

Commit

Permalink
Fix translation of \n and \\s into language files.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 13, 2020
1 parent adeed18 commit 9c9b73e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions htdocs/core/class/translate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir =
//if ($key == 'Order') print "Domain=$domain, found a string for key=$key=$tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."<br>";
if (empty($this->tab_translate[$key]))
{ // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
$value = preg_replace('/\\n/', "\n", $value); // Parse and render carriage returns
if ($key == 'DIRECTION') { // This is to declare direction of language
if ($alt < 2 || empty($this->tab_translate[$key])) { // We load direction only for primary files or if not yet loaded
$this->tab_translate[$key] = $value;
Expand All @@ -307,8 +306,8 @@ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir =
continue;
}
else {
$this->tab_translate[$key] = $value;
//if ($domain == 'orders') print "$tab[0] value $value<br>";
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
if ($usecachekey) {
$tabtranslatedomain[$key] = $value;
} // To save lang content in cache
Expand Down Expand Up @@ -491,9 +490,9 @@ public function loadFromDatabase($db)
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
{
$value=trim(preg_replace('/\\n/', "\n", $value));
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);

$this->tab_translate[$key]=$value;
if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
}

Expand Down Expand Up @@ -618,9 +617,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 =
}
}

if (! preg_match('/^Format/', $key))
if (strpos($key, 'Format') !== 0)
{
//print $str;
$str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
}

Expand Down

0 comments on commit 9c9b73e

Please sign in to comment.