PHP Classes

Multiple Language Script without Database: Get application language texts from files

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 260 All time: 7,809 This week: 79Up
Version License PHP version Categories
multilanguage-script 1.0Freeware5.0Localization, PHP 5


This class can get application language texts from files.

It can get the current user preferred language from session, GET or POST variables.

The class loads a text file with application texts from a file which contains the text for each application text string in different languages.

The class returns a given application text in a given supported language.

Currently it supports English, Spanish and French languages.

The class can also add new application texts to the translations file.

Picture of Bharat Parmar
  Performance   Level  
Name: Bharat Parmar <contact>
Classes: 11 packages by
Country: India India
Age: 33
All time rank: 51831 in India India
Week rank: 311 Up20 in India India Up
Innovation award
Innovation award
Nominee: 3x



$Main = new MultiLanguage();
<meta charset="UTF-8">
<title>Example Script</title>
    <b>Change Language : </b>
        <a href="?language=english">English</a> &nbsp;&nbsp;&nbsp;
        <a href="?language=spanish">Spanish</a> &nbsp;&nbsp;&nbsp;
        <a href="?language=french">French</a> &nbsp;&nbsp;&nbsp;
    <table border="1" width="50%">
        <caption>Default Language Demo</caption>
            <th><?php echo ucfirst($_SESSION['language']);?></th>
            <td><?php $Main->LanguageString("Hello");?></td>
            <td><?php $Main->LanguageString("Bye");?></td>
            <td><?php $Main->LanguageString("Thank You");?></td>
    <table border="1" width="50%">
        <caption>Different Languages Demo</caption>
            <td><?php $Main->LanguageString("Hello","english");?></td>
            <td><?php $Main->LanguageString("Hello","spanish");?></td>
            <td><?php $Main->LanguageString("Hello","french");?></td>
            <td><?php $Main->LanguageString("Bye","english");?></td>
            <td><?php $Main->LanguageString("Bye","spanish");?></td>
            <td><?php $Main->LanguageString("Bye","french");?></td>
            <td><?php $Main->LanguageString("Thank You","english");?></td>
            <td><?php $Main->LanguageString("Thank You","spanish");?></td>
            <td><?php $Main->LanguageString("Thank You","french");?></td>


Project : Multiple Language Script without Database Developed By : Bharat Parmar Version : 1.0 ==================== File Structure : ================== 1) index.php : Example Script file to display Language String with Default and other languages 2) addphrase.php : Add/Edit all languages string to language file. 3) language.txt : Text file which includes all language strings 4) MultiLanguage.class.php : Class file which includes all the method to Read and Write Language file and Displaying the Language String as per the requirement. Requirements : ================== 1) PHP Version : 5.0 and above 2) language.txt file read & write permission. Script Details : ================== 1) $_SESSION['language'] : This session will store the default language for the user. By Default English. If you want to change the default language, You can change it from the MultiLanguage.class.php file's contrust() method. 2) LanguageString() : Parameter : 1 => Language String which you want to display. It must be in English Language Only. 2 => Language name in which you want to display the string like english/spanish/french. This parameter is optional. By Default it will display the default language string. Use : For Default Language : <?php $Main->LanguageString("Hello");?> => Hello <?php $Main->LanguageString("Bye");?> => Bye For Other Language : <?php $Main->LanguageString("Hello","spanish");?> <?php $Main->LanguageString("Hello","french");?> <?php $Main->LanguageString("Bye","spanish");?> <?php $Main->LanguageString("Bye","french");?> Please check the index.php file for the same. Example script for the same. 3) WriteLanguageFile() : If you want to update the language string or add new string, you can add/edit from the addphrase.php file. After submitting the form, all the string will be added with the above method. It will re-write the language.txt file. Please note that the language.txt file must have the 0755 permission to read and write.

  Files folder image Files  
File Role Description
Accessible without login Plain text file addphrase.php Example You can Add and Edit the Language Phases as per requirement
Accessible without login Plain text file index.php Example Demo script to use the class and display string in multiple language
Accessible without login Plain text file language.txt Data all the language strings will be stored here.
Plain text file MultiLanguage.class.php Class Class file which includes all the methods to use the script. Very sort and simple code
Accessible without login Plain text file README.txt Doc. Documentation file for the script.

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,809
This week:79Up