PHP Classes

PHP Multilang: Get translated application texts for languages

Recommend this page to a friend!
  Info   Example   Videos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 55%Total: 555 All time: 5,487 This week: 79Up
Version License PHP version Categories
multilang 1.0.0GNU Free Document...3.0Localization, PHP 5
Description 

Author

This class can get translated application texts for different languages.

It can parse a file and extract texts for application strings in different languages.

The class can return text for named strings for the currently selected language.

Picture of Jake Bown
  Performance   Level  
Name: Jake Bown <contact>
Classes: 3 packages by
Country: United Kingdom
Age: 31
All time rank: 2823130 in United Kingdom
Week rank: 206 Up12 in United Kingdom Up

Example

<?php include("multilang.php"); $i = new multilang("en"); ?>
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
    <title>Simple Translate</title>
</head>
<body>
<h1><?= $i->say("example_header"); ?></h1>
<p><?= $i->say("heading_summary"); ?></p>

</body>
</html>


Details

Simple PHP Multi-Language

Simple PHP Multi-Language is a dead simply way of translating your projects without using a database.

Why did I make this?

After working on a number of projects that needed translating into both French and German from English, the handover and translation process took extremely long and often became confusing, especially when the english version we're tweaked and other languages needed updating again (terrible for revising).

How does it work?

Simply by including the multilang class in your projects, you can quickly plug a translation file into your project and get busy being multilingual.

The translate file is set out exactly the same as a CSS file, for simplicity, each country is differenciated by its language prefix/code (DE, FR, EN) and can be set a number of different ways (see examples).

@welcome_message {
	
}

How to translate

All you need to do is edit the "translate.lang" file and start creating language ID's, this is done by naming each ID starting with "@". You then simply add the languages you wish to support by adding the prefix:

@welcome_message {
	en: "hello";
	fr: "bonjour";
}

and echo it out in php by using the "say" function:

<?=$var->say("welcome_message");?>

You can add as many translation as you wish to your translations ID's.

Updates

Please let me know your thoughts and suggestions to make PHP-Multilang better for everyone!


  Files folder image Files (7)  
File Role Description
Accessible without login Plain text file Example-1.php Example Example #1
Accessible without login Plain text file Example-2.php Example Example #2
Accessible without login Plain text file Example-Render.php Example Render with handlebars
Accessible without login Plain text file example_include_me.html Data Needed for the render demo
Plain text file multilang.php Class Multilang Class
Accessible without login Plain text file README.md Doc. Readme
Accessible without login Plain text file translate.lang Data Main translation file

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  
 0%
Total:555
This week:0
All time:5,487
This week:79Up
 User Ratings  
 
 All time
Utility:66%StarStarStarStar
Consistency:66%StarStarStarStar
Documentation:66%StarStarStarStar
Examples:50%StarStarStar
Tests:-
Videos:41%StarStarStar
Overall:55%StarStarStar
Rank:1922