PHP Classes

OnTime PHP Multi Language trait: Store and retrieve each user application language

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 79 All time: 10,122 This week: 79Up
Version License PHP version Categories
multilanguage 1.0Public Domain5Localization, PHP 5, Databases, Traits
Description 

Author

This package can store and retrieve all the content in different languages, each user even anonymous can read in different language.

It provides several traits that can be used to compose any class that needs to use texts to adapt an application to work using a language that the users prefer. Currently the package can:

- Store the list of supported languages
- Set the default language
- Set the language specific to the current user

Innovation Award
PHP Programming Innovation award winner
April 2021
Winner


Prize: SourceGuarding PHP encoder tool
Many applications need to support multiple languages, so they can be used by people that understand only their native languages.

Therefore applications need to keep track what is the language that each user prefers.

This package provides a solution that can store in a database the language that each user will see the application texts.

Manuel Lemos
Picture of Mario Carrocera
  Performance   Level  
Name: Mario Carrocera is available for providing paid consulting. Contact Mario Carrocera .
Classes: 18 packages by
Country: Mexico Mexico
Age: 59
All time rank: 309536 in Mexico Mexico
Week rank: 180 Up3 in Mexico Mexico Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php

ini_set
('display_errors', true);
error_reporting(E_ERROR | E_PARSE | E_NOTICE | E_WARNING);

$base='ontime/';
$AdminPassword='OT2021Free';
include_once(
$base."OnTime.php");
$demo=new OnTime();
echo
"**********+++++++++++ <br> Basic Table Demo <br> **********+++++++++++ <br> <br>";
echo
"********** <br> Create Class <br> ********** <br> <br>";
$demo->ot_error('basic content exist').'<br>';
echo
"**********+++++++++++ <br> Conecting like admin <br> **********+++++++++++ <br> <br>";
echo
"Connect('admin','OT2021Free') ";
$demo->Connect('admin',$AdminPassword);
echo
"<br>";$demo->ot_error("Connected!!!");echo "<br>";


echo
"********** <br> Defining Data dictyonary for General Porpuse <br> ********** <br> <br>";

$demo->DddAddFld('RecId', array('FldTpe'=>'K','FldDsc'=>'Record Identifier'));
$demo->DddAddFld('RecId', array('FldTpe'=>'K','FldDsc'=>'Record Identifier'));
$demo->DddAddFld('Name', array('FldTpe'=>'S','FldDsc'=>'Store the name'));
$demo->DddAddFld('Name', array('FldTpe'=>'S','FldDsc'=>'Store the name'));
$demo->DddAddFld('File', array('FldTpe'=>'P','FldDsc'=>'Name of the free text'));
$demo->DddAddFld('File', array('FldTpe'=>'P','FldDsc'=>'Name of the free text'));
$demo->DddAddFld('Img', array('FldTpe'=>'l','FldDsc'=>'Name of the image'));
$demo->DddAddFld('Img', array('FldTpe'=>'l','FldDsc'=>'Name of the image'));

echo
"********** <br> Defining Lenguages in main<br> ********** <br> <br>";

echo
"********** <br> Defining Lenguages <br> ********** <br> <br>";
$name = 'Lenguages';
$name = 'Lenguages';
$demo->CrtRcd($name,'Lenguages');
$demo->CrtRcd($name,'Lenguages');
$demo->RcdAddIn($name,'RecId', array('FldEmp'=>FALSE));
$demo->RcdAddIn($name,'RecId', array('FldEmp'=>FALSE));
$demo->RcdAddIn($name,'Name', array('FldEmp'=>FALSE));
$demo->RcdAddIn($name,'Name', array('FldEmp'=>FALSE));
$demo->RcdAddIn($name,'Img', array('FldEmp'=>TRUE));
$demo->RcdAddIn($name,'Img', array('FldEmp'=>TRUE));

echo
"********** <br> Activating tables in main & cresating lenguage<br> ********** <br> <br>";

echo
"CrtFtrTbl('main')";
$demo->CrtFtrTbl('main');
echo
"CrtTblIn('Lenguages', 'Lenguages avaible on sisitem', 'Lenguages' , 'main')";
$demo->CrtTblIn('Lenguages', 'Lenguages avaible on sisitem', 'Lenguages' , 'main');

echo
"********** <br> Inserting English like lenguage <br> ********** <br> <br>";
echo
"InsTblIn('Lenguages' , 'En', array('Name'=>'English', 'Img'=> 'usa flag'),'main')";
$demo->InsTblIn('Lenguages' , 'En', array('Name'=>'English', 'Img'=> 'usa flag'),'main');
echo
"********** <br> Inserting Spanish like lenguage <br> ********** <br> <br>";
echo
"InsTblIn('Lenguages' , 'Es', array('Name'=>'Español', 'Img'=> 'bandera española'),'main')";
$demo->InsTblIn('Lenguages' , 'Es', array('Name'=>'Español', 'Img'=> 'bandera española'),'main');
echo
"********** <br> Inserting Spanish mexico like lenguage <br> ********** <br> <br>";
echo
"InsTblIn('Lenguages' , 'Mx', array('Name'=>'Español (México)', 'Img'=> 'bandera mexicana'),'main')";
$demo->InsTblIn('Lenguages' , 'Mx', array('Name'=>'Español (México)', 'Img'=> 'bandera mexicana'),'main');

echo
"********** <br> Set english to default lenguage <br> ********** <br> <br>";
echo
"LngDflSys('En')";
$demo->LngDflSys('En');

echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngFllSys('yes')";
$demo->LngFllSys('yes');

echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngRad('Es')";
$demo->LngRad('Es');
echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngRadMsr('Es')";
$demo->LngRadMsr('Es');
echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngWrtMsr('Es')";
$demo->LngWrtMsr('Es');
echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngWrtSys('Es')";
$demo->LngWrtSys('Es');
echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngRadUsr('Es','Admin')";
$demo->LngRadUsr('Es','Admin');
echo
"********** <br> Set read mode like full (if something is not en the leguage read default) <br> ********** <br> <br>";
echo
"LngWrtUsr('Es','Admin')";
$demo->LngWrtUsr('Es','Admin');


echo
"**********+++++++++++ <br> Demo Finish<br> **********+++++++++++ <br> <br>";
?>


Details

Trait Tablefor ontime

The OnTime framework is designed to be modular, scalable and comprehensive, so that each new feature integrates without difficulty and maintains a unique class definition (OnTime) and all "additional classes" are "trait" that enrich it, in such a way that an integrated system is obtained, not separate programs which do not necessarily have to behave correctly together. This trait will be need if you wan have tables

Installation in test environment:

1.- Copy all the files in the directory where was instaled ontrime core

2.- With the browser of your preference, locate the directory and enter it

3.- Execute the OntimeInstallerDyR.php file

4.- When executing the file, the files where moved and the required environment was created

Recommendations:

If you know how to create a subdomain that points to the "demo" directory, it is more comfortable and realistic.

After install

When installing, the necessary environment is defined to define access security, I create a User called "Admin" and that his password is "OT2021Free", this environment left the class prepared for definitions of the data dictionary and records.

In this trait, can create tables in any feature, a table is defined like a record that have an unique Key id, when you create a table must especify the record, but more than one table can have the same record, in a record must include at least all the fields that don't is not specy like emty = TRUE, neither can include a fields not included on the record.

In the validation include since this feature

lookin, check that the content of the field exist in defined basic content feature (.bas) lookfrom, check that the content of the field exist in defined table feature (.tas) bringin, check that the content of the field exist in defined basic content feature (.bas), and bring the relate data like %%Field bringfrom, check that the content of the field exist in defined table feature (.tas), , and bring the relate data like %%Field isin, check that the content of the field exist is defined container in basic content feature (.bas) isfrom, check that the content of the field exist is defined container in defined table feature (.tas)

mario.carrocera@hotmail.com +++++++++++ Basic Multilenguage Demo +++++++++++

Create Class

basic content exist +++++++++++ Conecting like admin +++++++++++

Connect('admin','OT2021Free') Connected!!!

Defining Data dictyonary for General Porpuse

Defining Lenguages in main

Defining Lenguages

Activating tables in main & cresating lenguage

CrtFtrTbl('main')CrtTblIn('Lenguages', 'Lenguages avaible on sisitem', 'Lenguages' , 'main') Inserting English like lenguage

InsTblIn('Lenguages' , 'En', array('Name'=>'English', 'Img'=> 'usa flag'),'main') Inserting Spanish like lenguage

InsTblIn('Lenguages' , 'Es', array('Name'=>'Español', 'Img'=> 'bandera española'),'main') Inserting Spanish mexico like lenguage

InsTblIn('Lenguages' , 'Mx', array('Name'=>'Español (México)', 'Img'=> 'bandera mexicana'),'main') Set english to default lenguage

LngDflSys('En') Set read mode like full (if something is not en the leguage read default)

LngFllSys('yes') Set read mode like full (if something is not en the leguage read default)

LngRad('Es') Set read mode like full (if something is not en the leguage read default)

LngRadMsr('Es') Set read mode like full (if something is not en the leguage read default)

LngWrtMsr('Es') Set read mode like full (if something is not en the leguage read default)

LngWrtSys('Es') Set read mode like full (if something is not en the leguage read default)

LngRadUsr('Es','Admin') Set read mode like full (if something is not en the leguage read default)

LngWrtUsr('Es','Admin')+++++++++++ Demo Finish +++++++++++

DddAddFld('Dscr', array('FldTpe'=>'S','FldDsc'=>'Store the Description')) Created!!!

Create field DscPrm in data dictionary

DddAddFld('DscPrm', array('FldTpe'=>'S','FldDsc'=>'Description of parameters')) Created!!!

Create field FlDName in data dictionary

DddAddFld('DscErr', array('FldTpe'=>'A','FldDsc'=>'Errors tat can present')) Created!!!

Show Data Dictionary

ShwDdd() 1.- FldNme : __________1D.- FldTpe=>K __________1D.- FldDsc=>Field name 1.- FldDsc : __________1D.- FldTpe=>S __________1D.- FldDsc=>Field description 1.- FldTpe : __________1D.- FldTpe=>R __________1D.- FldDsc=>Field type ----------2.- FldVld : ____________________2D.- Name=>lookin ____________________2D.- content=>type ____________________2D.- in=>ddd 1.- FldVld : __________1D.- FldTpe=>A __________1D.- FldDsc=>Field validation 1.- FldLen : __________1D.- FldTpe=>I __________1D.- FldDsc=>Field length 1.- FldEmp : __________1D.- FldTpe=>B __________1D.- FldDsc=>Field bool 1.- FldFmt : __________1D.- FldTpe=>S __________1D.- FldDsc=>Field format 1.- FldCap : __________1D.- FldTpe=>S __________1D.- FldDsc=>Field caption 1.- FldTtt : __________1D.- FldTpe=>S __________1D.- FldDsc=>Field tool tip text 1.- FldDfl : __________1D.- FldTpe=>V __________1D.- FldDsc=>Default Value __________1D.- FldEmp=> 1.- RecId : __________1D.- FldTpe=>K __________1D.- FldDsc=>Record Identifier 1.- Name : __________1D.- FldTpe=>S __________1D.- FldDsc=>Store the name 1.- in : __________1D.- FldTpe=>S __________1D.- FldDsc=>Store Trait where is instales 1.- parameters : __________1D.- FldTpe=>I __________1D.- FldDsc=>Number of Parameters 1.- Dscr : __________1D.- FldTpe=>S __________1D.- FldDsc=>Store the Description 1.- DscPrm : __________1D.- FldTpe=>S __________1D.- FldDsc=>Description of parameters 1.- DscErr : __________1D.- FldTpe=>A __________1D.- FldDsc=>Errors tat can present Defining Record for sample

Create Record sample in data dictionary

CrtRcd(sample,'sample of ontime') Created!!!

Add field RecId Name to record

RcdAddIn(sample,'RecId', array('FldEmp'=>FALSE)) Created!!!

Add field Name to record

RcdAddIn(sample,'Name', array('FldEmp'=>TRUE)) Created!!!

Add field in to record

RcdAddIn(sample,'in', array('FldEmp'=>FALSE)) Created!!!

Add field parameters to record

RcdAddIn(sample,'parameters', array('FldEmp'=>FALSE)) Created!!!

Add field Dscr to record

RcdAddIn(sample,'Dscr', array('FldEmp'=>TRUE)) Created!!!

Add field DscPrm to record

RcdAddIn(sample,'DscPrm', array('FldEmp'=>TRUE)) Created!!!

Add field DscErr to record

RcdAddIn(sample,'DscErr', array('FldEmp'=>TRUE)) Created!!!

Show record list

ShwRecLst() 0D.- ddd=>Data Dictionary 0D.- sample=>sample of ontime Show record

ShwRec('sample') 1.- definition : __________1D.- key=>RecId ----------2.- RecId : --------------------3.- ByField : ______________________________3D.- FldTpe=>K ______________________________3D.- FldDsc=>Record Identifier --------------------3.- ByRecord : ______________________________3D.- FldEmp=> ----------2.- Name : --------------------3.- ByField : ______________________________3D.- FldTpe=>S ______________________________3D.- FldDsc=>Store the name --------------------3.- ByRecord : ______________________________3D.- FldEmp=>1 ----------2.- in : --------------------3.- ByField : ______________________________3D.- FldTpe=>S ______________________________3D.- FldDsc=>Store Trait where is instales --------------------3.- ByRecord : ______________________________3D.- FldEmp=> ----------2.- parameters : --------------------3.- ByField : ______________________________3D.- FldTpe=>I ______________________________3D.- FldDsc=>Number of Parameters --------------------3.- ByRecord : ______________________________3D.- FldEmp=> ----------2.- Dscr : --------------------3.- ByField : ______________________________3D.- FldTpe=>S ______________________________3D.- FldDsc=>Store the Description --------------------3.- ByRecord : ______________________________3D.- FldEmp=>1 ----------2.- DscPrm : --------------------3.- ByField : ______________________________3D.- FldTpe=>S ______________________________3D.- FldDsc=>Description of parameters --------------------3.- ByRecord : ______________________________3D.- FldEmp=>1 ----------2.- DscErr : --------------------3.- ByField : ______________________________3D.- FldTpe=>A ______________________________3D.- FldDsc=>Errors tat can present --------------------3.- ByRecord : ______________________________3D.- FldEmp=>1 1.- in : Activate Table feature

ShwRec('sample') C0010M007.-Error not defined

Creating tables

CrtTblIn('My sample', 'My Sample', 'sample' Created!!!

CrtTblIn('Sample 2', 'My Sample', 'sample' Created!!!

Show featrures with tables

ShwFtrTbl() 0D.- table=>(table) Table Feature Show features with tables

ShwFtrTbl() 0D.- index=>Main index 0D.- My sample=>My Sample 0D.- Sample 2=>Other sample same record Show tables

ShwTbl('My sample') Insert Records in My Sample

InsTblIn('My sample' , 'rec 1', array('Name'=>'Just a description','in'=>'Mexico City','parameters'=>8)) Show tables

ShwTbl('My sample') Insert Records in My Sample

InsTblIn('My sample' , 'rec 2', array('Name'=>'another description','in'=>'Mexico City','parameters'=>8,'DscPrm'=>'explain what do')) Show tables

ShwTbl('My sample') Insert Records in My Sample

InsTblIn('My sample' , 'rec 3', array('Name'=>'another description','in'=>'Mexico City','parameters'=>8)) Show tables

ShwTbl('My sample') Update and Mix in My Sample

UpmTblIn('My sample' , 'rec 3', array('Name'=>'refresh again description','DscPrm'=>'who cares')) Show tables

ShwTbl('My sample') Update with replace in My Sample

UpdTblIn('My sample' , 'rec 2', array('Name'=>'another description','in'=>'Mexico ','parameters'=>2)) Show tables

ShwTbl('My sample') delete in My Sample

dltTblIn('My sample' , 'rec 1') Show tables

ShwTbl('My sample') +++++++++++ Demo Finish +++++++++++


  Files folder image Files (12)  
File Role Description
Accessible without login Plain text file DemoMultilenguage.php Example Example script
Accessible without login Plain text file licencia Data Auxiliary data
Accessible without login Plain text file license Lic. License text
Accessible without login Plain text file OnTime.php Aux. Auxiliary script
Plain text file OnTimeAllways.php Class Class source
Plain text file OnTimeCripto.php Class Class source
Accessible without login Plain text file OntimeInstallerMulti.php Example Example script
Plain text file OnTimeLenguageA.php Class Class source
Plain text file OnTimeLenguageB.php Class Class source
Accessible without login Plain text file OnTimetmp.php Aux. Auxiliary script
Plain text file OnTimeValid.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadmultilanguage-2021-05-31.zip 12KB
Downloadmultilanguage-2021-05-31.tar.gz 10KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
HTML Include Images and Text using PHP on Time Download .zip .tar.gz Implement image & text Optional
HTML Nav bar using PHP on Time Download .zip .tar.gz Implements a Nav Bar Optional
HTML LayOut using PHP on Time Download .zip .tar.gz Implement Layout Optional
HTML CSS Styles using PHP on Time Download .zip .tar.gz Implements Css Html Optional
HTML Google Fonts using PHP on Time Download .zip .tar.gz Implement Google Font on HTML Optional
HTML Metatags using PHP on Time Download .zip .tar.gz Html Meta Tag pacakage Optional
Easy PHP SOAP Server Web Service Download .zip .tar.gz Add soap webservice server Required
OnTime Table Trait Download .zip .tar.gz Add Data Dictuionary and record information Required
On Time Data Dictionary and Record Trait Download .zip .tar.gz Add Data Dictuionary and record information Required
OnTime Timezones and Formats Trait Download .zip .tar.gz Add Date, time & timezones managemt Required
OnTime Debugger Backend Trait Download .zip .tar.gz Add the ability to debug the class Required
OnTime Basic Content Trait Backend Download .zip .tar.gz Add Simple 2 field tables Required
OnTime Group Backend Download .zip .tar.gz Add Group Manager Required
OnTime Core Backend Download .zip .tar.gz the main class hold usrs and featrure Required
 Version Control Reuses Unique User Downloads Download Rankings  
 100%8
Total:79
This week:0
All time:10,122
This week:79Up