PHP Classes

PHP Translate Text: Get application text translations from INI files

Recommend this page to a friend!
  Info   View files Example   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 81 All time: 10,054 This week: 96Up
Version License PHP version Categories
translator-class 1.0.0BSD License5Localization, PHP 5, Configuration
Description 

Author

This package gets application text translations from INI files.

The package can read PHP INI files from a given directory that contains a translation of texts.

There can be separate translation files for each language supported by an application.

The package can return the text translation given the original text string from the primary language that can be English into the translated language.

Picture of Aleksandar Zivanovic
  Performance   Level  
Name: Aleksandar Zivanovic <contact>
Classes: 16 packages by
Country: Serbia Serbia
Age: 30
All time rank: 16237 in Serbia Serbia
Week rank: 312 Up2 in Serbia Serbia Up
Innovation award
Innovation award
Nominee: 4x

Example

<?php

use Translate\Translator;

require_once
__DIR__ . '/../vendor/autoload.php';

$T = new Translator('en_US', __DIR__ . '/translations');

// Basic translate
echo $T->translate('WELCOME') . "\n";

// Translate with replacable placeholders
// NOTE: not defining section nor strict only - script will look for first translation with id "CREATED"
echo $T->translate('CREATED', [':username:' => 'Test User']) . "\n";

// Translate with replacable placeholders
// NOTE: defining section without using strict only, script will look for "CREATED" in section "BLOG_POST"
echo $T->translate('CREATED', [':username:' => 'BestUser', ':title:' => 'Post Title'], 'BLOG_POST') . "\n";

// Translate with replacable placeholders
// NOTE: defining section while using strict only - script wil throw an exception if requested identifier doesn't exist
// in provided section
echo $T->translate('REMOVED', [':username:' => 'BestUser', ':title:' => 'Its a title'], 'USER', true);


  Files folder image Files  
File Role Description
Files folder image.idea (1 file)
Files folder imageexample (1 file, 1 directory)
Files folder imagesrc (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data

  Files folder image Files  /  .idea  
File Role Description
  Accessible without login Plain text file vcs.xml Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
Files folder imagetranslations (2 files)
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  example  /  translations  
File Role Description
  Accessible without login Plain text file en_US.ini Data Auxiliary data
  Accessible without login Plain text file sr_RS.ini Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file TranslationLine.php Class Class source
  Plain text file Translator.php Class Class source
  Plain text file TranslatorException.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:81
This week:0
All time:10,054
This week:96Up