Multiple variables in Language Key

Hello again, I have another question/idea which I hope is an easy one. Is it possible to put multiple variables in a language key. I know how to do a single variable. in my code:

_t("_Keyname", $variable_from_sql_script)

and create a key called _Keyname:

This is the result of the variable {0}

Now, I have this:

(Again, this is a report generated by <?php echo $title ?> <strong><?php echo $FirstName; ?></strong> <strong><?php echo $LastName ?></strong> on <strong><?php echo $dateend ?></strong> ).

And was curious if there was a way to use multiple variables ($title, $FirstName, $LastName, $dateend) in a language key like this:

(Again, this is a report generated by {0} <strong>{1}</strong> <strong>{2}</strong> on <strong>{3}</strong> ).

but, unfortunately, I can only get 3 variables to display, ( {3} displays as {3}). Is there someplace where I need to increase the number of variables than can be used, or is this just the way it is.

Any help would be appreciated, and again, Thanks in advance.

caredesign.net
Quote · 29 Mar 2013

The programmed limit is 3

https://www.deanbassett.com
Quote · 30 Mar 2013

You can reprogram to allow more than 3. The language functions such as _t are in inc/languages.inc.php

But there is also a javascript version of that function somewhere as well. I just don't remember where.

https://www.deanbassett.com
Quote · 30 Mar 2013

THANK YOU SO MUCH DEANO!!!!!!!. I would kiss you if I could. You have just made my life so much easier. I added the variables in the inc/language.inc.php file and it is working like a charm.

Now, to explain a little bit of why i needed this. There are a large number of "assessments" that are being used, and each profession type has its own set of "assessments" - but, the ending output of all the data entered for a specific assessment, is duplicated on other assessments.

example:

{0} has listed {1} emergency point of contact as <strong>{2} {3}</strong> (<strong>{4}</strong>) at <strong>{5}</strong>.)<br />

so putting this on each page is a lot easier and the page is more easily readable in case someone needs to get in and make some changes After I am done.

<?php echo _t("_Emergency contact txt", $genderlow, $sexlow, $eFirstName, $eLastName, $ecrelationship, $ecphone1); ?>

And this is just one example. There are about 120 small sections in which i could make keys with one or two variables and that would have been fine.

But a lot of the small sections make up a larger section, so being able to add more variables decreases the amount of time I need to spend on each page, it is just simply putting in the language key code .

And with cleaning this up, it has also added a new idea into my head. Avariation of the page blocks within a single page block itself. use tha language keys, to allow a user to choose which sections he/she wants to show, and in what order they want to show them in.

Thanks again Deanos

caredesign.net
Quote · 30 Mar 2013

Just as an FYI, I have a section with 11 variables, and just making the changes in the inc/languages.inc.php allow all to show perfectly.

caredesign.net
Quote · 30 Mar 2013

You could do something a bit more advanced.  Origional function.

function _t($key, $arg0 = "", $arg1 = "", $arg2 = "")
{
    global $LANG;

    if(isset($LANG[$key])) {
        $str = $LANG[$key];
        $str = str_replace('{0}', $arg0, $str);
        $str = str_replace('{1}', $arg1, $str);
        $str = str_replace('{2}', $arg2, $str);
        return $str;
    } else {
        return $key;
    }
}


New version.

function _t()
{
    global $LANG;
    $arg_list = func_get_args();
    $key = func_get_arg(0);
    if(isset($LANG[$key])) {
        $str = $LANG[$key];
    $arg_list = func_get_args();
    foreach($arg_list as $id => $value) {
         if($id>0) $str = str_replace('{' . $id . '}', $value, $str);
    }
        return $str;
    } else {
        return $key;
    }
}


I have not tested the new version of this function. But if i wrote it correctly it allows any number of arguments to be passed. The first one is always to be the language key as normal. The rest would be any number of optional variables.

https://www.deanbassett.com
Quote · 30 Mar 2013

New dillemma:

how to turn the following code into a language key. It contains a table that uses javascript functions for sorting and creation of the table.

 

<link href="../YUI/2.6.0/build/fonts/fonts-min.css" rel="stylesheet" type="text/css" />
<link href="../YUI/2.6.0/build/datatable/assets/skins/sam/datatable.css" rel="stylesheet" type="text/css" />
<script src="../YUI/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script>
<script src="../YUI/2.6.0/build/element/element-beta-min.js" type="text/javascript"></script>
<script src="../YUI/2.6.0/build/datasource/datasource-min.js" type="text/javascript"></script>
<script src="../YUI/2.6.0/build/datatable/datatable-min.js" type="text/javascript"></script>

echo "</br><div id='yuidatatable1190152'>
<table width='100%' id='yuidatatable1190152_src'>
                <thead>
                  <tr>
                    <th>Type</th>
                    <th><strong>Frequency</strong></th>
                    <th><strong>Length</strong></th>
                    <th><strong>Physician</strong></th>
                    <th><strong>Current</strong></th>
                  </tr>
                </thead>
                <tbody>"; 
 
$exercise = mysql_query("SELECT * FROM exercise WHERE user_id = '$client'"); 
while ($row_exercise = mysql_fetch_array($exercise)) { 
$Type = $row_exercise["ExcType"];
$Frequency = $row_exercise["ExcFreq"];
$Length = $row_exercise["ExcLength"];
$Concern = $row_exercise["ExcConcern"];
$Current = $row_exercise["current"];

    echo "<tr> 
    <td> 
$Type</td> 
    <td> 
$Frequency</td> 
    <td> 
$Length</td>
    <td> 
$Concern</td>
    <td> 
$Current</td>
    </tr>"; 
$row_count++; 
     

echo "</table>
</div>"; 
 ?>
<script type="text/javascript">
// BeginWebWidget YUI_DataTable: yuidatatable1190152
 
(function() { 
  var cn = document.body.className.toString();
  if (cn.indexOf('yui-skin-sam') == -1) {
    document.body.className += " yui-skin-sam";
  }
})();
 
var inityuidatatable1190152 = function() {
  var yuidatatable1190152_columnDef = [
    {key:"type",label:"Type",sortable:true},
    {key:"frequency",label:"Frequency",sortable:true},
    {key:"length",label:"Length",sortable:true},
    {key:"concern",label:"Concern",sortable:true},
    {key:"current",label:"Current",sortable:true}
  ];
 
  this.parseNumberFromCurrency = function(sString) {
    return parseFloat(sString.substring(1));
  };
 
  this.yuidatatable1190152_DS = new YAHOO.util.DataSource(YAHOO.util.Dom.get("yuidatatable1190152_src"));
  this.yuidatatable1190152_DS.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
  this.yuidatatable1190152_DS.responseSchema = {
    fields: [
    {key:"type"},
      {key:"frequency"},
      {key:"length"},
      {key:"concern"},
      {key:"current"}
    ]
  };
  var yuidatatable1190152 = new YAHOO.widget.DataTable("yuidatatable1190152", yuidatatable1190152_columnDef, this.yuidatatable1190152_DS);
 
  function columnSort() {
  }  
  yuidatatable1190152.subscribe("columnSortEvent", columnSort)
};
 
// Create the YUI DataTable when the HTML document is usable.
YAHOO.util.Event.onDOMReady(inityuidatatable1190152);
 
// EndWebWidget YUI_DataTable: yuidatatable1190152
            </script>

caredesign.net
Quote · 30 Mar 2013

is it possible to put javascript into a language key?

caredesign.net
Quote · 3 Apr 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.