09-12-2017, 07:28 PM
You can certainly do this, and fairly easily. Once it's set up, all you need to do is add your per-page translations (see below) for any pages you want both languages on.
The language file is located at. This file loads all the English translations into the array $lang. If you make a copy of this (for example), you can change all the translations into Spanish. Also, change all instances of $lang to $lang_es, and you can use the Spanish language array the same way as the English:
Be sure to copy and modify the lang() function in to create your new lang_es() function:
To add on to the array, you can include it in or simply on the page itself where needed:
This isn't the most elegant solution since the language feature was intended for one language at a time instead of multiple, but I'll look at updating this so you can specify your language in your lang() function call. Let me know if you are able to get this going!
The language file is located at
Code:
/users/helpers/language.php
Code:
file and name it language_es.php
Code:
<?= lang_es("SIGNUP_TEXT", ""); ?>
Be sure to copy and modify the lang() function in
Code:
us_helpers.php
Code:
function lang_es($key,$markers = NULL){
Code:
global $lang_es;
Code:
if($markers == NULL){
Code:
$str = $lang_es[$key];
Code:
}else{
Code:
//Replace any dyamic markers
Code:
$str = $lang_es[$key];
Code:
$iteration = 1;
Code:
foreach($markers as $marker){
Code:
$str = str_replace("{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}m".$iteration."{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}",$marker,$str);
Code:
$iteration++;
Code:
}
Code:
}
Code:
//Ensure we have something to return
Code:
if($str == ""){
Code:
return ("No se encontrĂ³ ninguna clave de idioma");
Code:
}else{
Code:
return $str;
Code:
}
Code:
}
To add on to the array, you can include it in
Code:
language.php
Code:
$lang = array_merge($lang, array(
Code:
"TRACKING_ERROR" => "There was an error retrieving the tracking number.",
Code:
"TRACKING_NUMBER" => "Tracking Number",
Code:
));
Code:
echo $lang('TRACKING_NUMBER', '') . ': ' . $trackingNumber;
This isn't the most elegant solution since the language feature was intended for one language at a time instead of multiple, but I'll look at updating this so you can specify your language in your lang() function call. Let me know if you are able to get this going!