KoolGrid support localization settings. You can change to another by loading corresponding language xml file. For example, to load Spanish language, you do:
$grid->Localization->Load("KoolControls/KoolGrid/localization/es.xml");
By creating new xml file, You can easily localize KoolGrid in your preferred language.
<?php
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolGrid/koolgrid.php";
require $KoolControlsFolder."/KoolGrid/ext/datasources/MySQLiDataSource.php";
if(isset($_POST["language_select"]))
{
$_SESSION["language_select"] = $_POST["language_select"];
}
else
{
if (!$koolajax->isCallback)
{
//Page Init: show default style
$_SESSION["language_select"] = "en";
}
}
$ds = new MySQLiDataSource($db_con);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
$ds->SelectCommand = "select customerNumber,customerName,phone,city from customers";
$ds->DeleteCommand = "delete from customers where customerNumber=@customerNumber";
$grid = new KoolGrid("grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder="default";
$grid->DataSource = $ds;
$grid->AjaxEnabled = true;
$grid->AllowDeleting = true;
$grid->AllowFiltering = true;
$grid->AutoGenerateColumns = true;
$grid->AutoGenerateDeleteColumn = true;
$grid->MasterTable->Pager = new GridPrevNextPager();
$grid->Width = "655px";
$grid->Localization->Load($KoolControlsFolder."/KoolGrid/localization/".$_SESSION["language_select"].".xml");
$grid->Process();
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
Select language:
<select id="language_select" name="language_select" onchange="submit();">
<option value="en" <?php if ($_SESSION["language_select"]=="en") echo "selected" ?> >English</option>
<option value="es" <?php if ($_SESSION["language_select"]=="es") echo "selected" ?> >Espanol</option>
<option value="it" <?php if ($_SESSION["language_select"]=="it") echo "selected" ?> >Italian</option>
<option value="vn" <?php if ($_SESSION["language_select"]=="vn") echo "selected" ?> >Vietnamese</option>
</select>
<div style="padding-top:10px;">
<?php echo $grid->Render();?>
</div>
</form>
<?xml version="1.0" encoding="utf-8" ?>
<localization xmlns="koolgrid:localization-schema">
<commands
Insert = "Nuevo"
Delete = "Eliminar"
Edit = "Editar"
Cancel = "Cancelar"
Confirm = "Confirmar"
Refresh = "Actualizar"
Done = "Hecho"
Loading = "Cargando..."
Go = " Ir "
Prev = "Anterior"
Next = "Siguiente"
No_Filter = "[N Filtro]"
Equal = "Igualdad"
Not_Equal = "No es igual"
Greater_Than = "Mayor que"
Less_Than = "Menos de"
Greater_Than_Or_Equal = "Mayor o igual"
Less_Than_Or_Equal = "Inferior o igual"
Contain = "Contener"
Not_Contain = "No Contener"
Start_With = "Comience con"
End_With = "Final con"
/>
<messages
DeleteConfirm = "Está seguro de eliminar esta fila?"
PageInfoTemplate = "Viendo la página {PageIndex} de {TotalPages}, puntos {FirstIndexInPage} a {LastIndexInPage} de un total de {TotalRows}."
ManualPagerTemplate = "Cambia la página: {TextBox} (de {TotalPage} páginas) {GoPageButton}"
PageSizeText = "Tamaño de página:"
PrevPageToolTip = "Página anterior"
NextPageToolTip = "Página siguiente"
SortHeaderToolTip = "Haga clic aquí para ordenar"
SortAscToolTip = "Ordenar ascendente"
SortDescToolTip = "Ordenar descendente"
InsertForm_ConfirmButtonToolTip = "Insertar Confirmar"
InsertForm_CancelButtonToolTip = "Insertar Cancelar"
EditForm_ConfirmButtonToolTip = "Confirmar los cambios"
EditForm_CancelButtonToolTip = "Cancelar cambios"
/>
</localization>