PHP Classes

PHP Language Selector class: Get texts for the current language from globals

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: 148 All time: 9,108 This week: 79Up
Version License PHP version Categories
php-language-selecto 1.0.1MIT/X Consortium ...5Localization, PHP 5
Description 

Author

This package can get texts for the current language from globals.

It can set the current application language to a certain language by specifying the associated language identifier name.

The class can load the texts for the specified language from scripts that are loaded dynamically.

Those scripts contain code that set a global variable with an array of texts which defines the translation of each string to the language that is set.

Picture of Muhammad Umer Farooq
Name: Muhammad Umer Farooq is available for providing paid consulting. Contact Muhammad Umer Farooq .
Classes: 52 packages by
Country: Pakistan Pakistan
Age: 23
All time rank: 84310 in Pakistan Pakistan
Week rank: 164 Up4 in Pakistan Pakistan Up
Innovation award
Innovation award
Nominee: 6x

Example

<?php

require_once 'core/init.php';

if (isset(
$_POST['lang'])) {
   
$lang = new Language();
   
$lang->SetLanguage($_POST['language']);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title><?= printl('home'); ?></title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <form action='' method="post" >
    <div class="form-group">
      <label for="language"><?= printl('select'); ?>:</label>
      <select class="form-control" id="language" name='language' >
        <option value='en'><?= printl('en'); ?></option>
        <option value='ur'><?= printl('ur'); ?></option>
      </select>
    </div>
    <div class="form-group" >
        <input type="submit" name="lang" class='btn btn-primary' value='<?= printl('submit'); ?>' />
    </div>
  </form>
</div>

</body>
</html>


Details

PHP Language Selector class

This package Can help create website support multi-language.

This package support 1. Language string/code seperate form html/php. 2. If language string/key not found in language file it return key that you supply/provide. 3. Require String class https://github.com/Lablnet/PHP-String-class

Description

This package can get texts for the current language from globals. It can set the current application language to a certain language by specifying the associated language identifier name. The class can load the texts for the specified language from scripts that are loaded dynamically. Those scripts contain code that set a global variable with an array of texts which defines the translation of each string to the language that is set.


  Files folder image Files (8)  
File Role Description
Files folder imagecore (1 file, 3 directories)
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files (8)  /  core  
File Role Description
Files folder imageclasses (2 files)
Files folder imagelibraries (1 file)
Files folder imagelocal (2 files)
  Accessible without login Plain text file init.php Aux. Auxiliary script

  Files folder image Files (8)  /  core  /  classes  
File Role Description
  Plain text file Language.php Class Class source
  Plain text file String.php Class Class source

  Files folder image Files (8)  /  core  /  libraries  
File Role Description
  Accessible without login Plain text file language.php Example Example script

  Files folder image Files (8)  /  core  /  local  
File Role Description
  Accessible without login Plain text file en.php Aux. Auxiliary script
  Accessible without login Plain text file ur.php Aux. Auxiliary script

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
 Version Control Unique User Downloads Download Rankings  
 100%
Total:148
This week:0
All time:9,108
This week:79Up