PHP Classes
elePHPant
Icontem

File: examples/example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Igor Crevar  >  icI18n  >  examples/example2.php  >  Download  
File: examples/example2.php
Role: Example script
Content type: text/plain
Description: second example
Class: icI18n
Get application text translations from XML files
Author: By
Last change:
Date: 4 years ago
Size: 1,475 bytes
 

Contents

Class file image Download
<?php
$thisPath
= dirname(__FILE__).'/';
require_once
dirname( $thisPath ).'/icI18n.class.php' ;

///set path for langs files
//current language is en(english) same as default language
icI18n::init('en', $thisPath.'langs2', 'en');

$langs = array('de', 'fr', 'sr');
$langsNames = array('de' => 'German', 'fr' => 'French', 'sr' => 'Serbian');

//create langs objects
foreach ($langs as $lang){
   
icI18n::addLanguage( new icI18nLanguage($lang) );
}

//first time pick translations from php files inside pages dir
foreach ($langs as $lang){
   
$oLang = icI18n::getLanguage($lang);
    if (!
$oLang->isEmpty()) continue;
   
$oLang->findAllTranslationStrings($thisPath.'pages/example2');
   
$oLang->toFile();
}

require_once(
$thisPath.'pages/example2/juststrings.php');

//output all translations on screen for german
echo '<h1>Original English</h1>';
//current language is english - we alreadt set that in init, but this is an example - who carres :)
icI18n::setCurrentLanguage('en');
printDetails();
foreach (
$langs as $lang){
    echo
'<h2>Translation on '.$langsNames[$lang].'</h2><br />';
   
icI18n::setCurrentLanguage($lang);
   
printDetails();
}


echo
'<br /><br />';
echo
'Sorry for all translations :). My native is serbian. I use google translate for all other languages :)';
echo
'<br /><br />';
echo
'If you want to edit translations edit xml files inside '.($thisPath.'langs2/').' and than clear '.
(
$thisPath.'langs2/cache').' directory';