View Issue Details

IDProjectCategoryView StatusLast Update
0012303mantisbtlocalizationpublic2010-08-27 14:15
Reporterdregad Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version1.2.1 
Summary0012303: custom_strings_inc.php called twice for English, resulting in wrong initialization of translation
Description

I have added a new severity to g_severity_enum_string, and following the documentation for custom enumerations, I created a custom_constant_inc.php for the new value, and a custom_strings_inc.php to initialize the translation properly.

I wanted to make it generic, to avoid having the @55@ code appearing for unhandled languages, so I tried to use a regexp function instead of a simple assignment, like this:

$s_severity_enum_string = preg_replace($s_search, $s_replace, $s_severity_enum_string);

This worked perfectly for all languages, except for English (default in config_default_inc.php), where $s_severity_enum_string was empty.

After some research, I realized that custom_strings_inc.php is actually called multiple times :

  1. english, with $s_severity_enum_string properly initialized
  2. english, with $s_severity_enum_string empty
  3. if current languages <> english, <language>, with $s_severity_enum_string properly initialized for that language

Obviously I have an easy workaround to this, by doing a simple assignment to the variable, but I do not understand why the custom_strings_inc.php is called twice for English. Is this normal behavior ?

Steps To Reproduce

Create a dummy custom_strings_inc.php as follows:

<?php
echo "$g_active_language - $s_severity_enum_string
";
?>

On top of every loaded page, you will see

english - 10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block
english -

Additional Information

For reference, here is my actual code (left only French language as an example)

<?php

switch ( $g_active_language ) {

case "french" :
    $s_medium = "moyen";
    break;
default:
    $s_medium = "medium";

}

Insert the translation string in the right place, between minor and major

$s_search = "/(" . MINOR . ":[^,]+),(" . MAJOR . ":)/i";
$s_replace = "$1," . MEDIUM . ":$s_medium,$2";
$s_severity_enum_string = preg_replace($s_search, $s_replace, $s_severity_enum_string);

?>

TagsNo tags attached.

Activities

There are no notes attached to this issue.