The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make additional $user variables?
#3
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
Code:
/users/helpers/language.php
. This file loads all the English translations into the array $lang. If you make a copy of this
Code:
file and name it language_es.php
(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:
Code:
<?= lang_es("SIGNUP_TEXT", ""); ?>

Be sure to copy and modify the lang() function in
Code:
us_helpers.php
to create your new lang_es() function:
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
or simply on the page itself where needed:
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!
  Reply


Messages In This Thread
Make additional $user variables? - by Katronix - 09-12-2017, 05:33 PM
Make additional $user variables? - by Katronix - 09-12-2017, 06:40 PM
Make additional $user variables? - by karsen - 09-12-2017, 07:28 PM
Make additional $user variables? - by Katronix - 09-12-2017, 07:49 PM
Make additional $user variables? - by karsen - 09-12-2017, 08:25 PM
Make additional $user variables? - by Katronix - 09-12-2017, 10:21 PM
Make additional $user variables? - by Brandin - 09-13-2017, 09:32 AM

Forum Jump:


Users browsing this thread: 6 Guest(s)