PHP Classes

Multi Language Translation with XML: Translate multiple strings in templates using XML

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 431 All time: 6,298 This week: 180Up
Version License PHP version Categories
multilanguage_xml 1.0GNU Lesser Genera...5.0XML, Localization, PHP 5, Templates


This class can translate multiple strings in templates using XML.

It can load the definition of application strings from a XML file for a given language.

The class can find and replace multiple text marks at once in a given template with the respective language texts.

Picture of pooya sabramooz
  Performance   Level  
Name: pooya sabramooz is available for providing paid consulting. Contact pooya sabramooz .
Classes: 4 packages by
Country: Iran Iran
Age: 33
All time rank: 150819 in Iran Iran
Week rank: 280 Up6 in Iran Iran Up
Innovation award
Innovation award
Nominee: 2x

Winner: 2x



include './class.multiLanguage.php';
$staticSection = file_get_contents('./menu.html');

// multiLanguage::getLanguage(); Default language is english
     // multiLanguage::getLanguage('es'); Set manual language
     // multiLanguage::getLanguage(@$_POST['language']); Set language with POST method of forms
     // multiLanguage::getLanguage(@$_GET['language']); Set language with GET method or Query string
$translatedMenu = multiLanguage::translateRecursive($staticSection);
<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Multilanguage Static Sections With Regular Expression">
    <meta name="author" content="pooya sabramooz">

    <title>Multilanguage Static Sections With Regular Expression</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="">

        html {
          position: relative;
          min-height: 100%;
        body {
          margin-bottom: 60px;
        .footer {
          position: absolute;
          bottom: 0;
          width: 100%;
          height: 60px;
          background-color: #f5f5f5;
        body > .container {
          padding: 60px 15px 0;
        .container .text-muted {
          margin: 20px 0;
        .footer > .container {
          padding-right: 15px;
          padding-left: 15px;


    <?php echo $translatedMenu; ?>

    <div class="container">
      <div class="page-header">
        <h3>Multi language sections with xml and Regular expression</h3>
      <p>Select a language...</p>
      <form method="post">
          English : <input type="submit" class="btn-link" name="language" value="en"><br>
          Spanish : <input type="submit" class="btn-link" name="language" value="es"><br>
        Farsi : <input type="submit" class="btn-link" name="language" value="fa"><br>
      <p>In addition, with this class you can change language of a page or just a section of a page.</p>

    <div class="footer">
      <div class="container">
        <p class="text-muted"> Pooya Sabramooz &lt;; </p>


  Files folder image Files  
File Role Description
Files folder imagelangs (3 files)
Plain text file class.multiLanguage.php Class Class source
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file menu.html Data Auxiliary data

  Files folder image Files  /  langs  
File Role Description
  Accessible without login Plain text file en.xml Data Auxiliary data
  Accessible without login Plain text file es.xml Data Auxiliary data
  Accessible without login Plain text file fa.xml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,298
This week:180Up
User Comments (1)
very good
9 years ago (Amir Mousavi)