BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/text/Bs_LanguageHandler.class.php
BlueShoes Application Framework - text

Bs_LanguageHandler

Bs_Object
   |
  +-- Bs_LanguageHandler

This class provides methods to work with different languages.

 

public class Bs_LanguageHandler extends Bs_Object

This class provides methods to work with different languages.
it uses files (like ini files, text files) for each language.example usage:put the following content into the file '/some/dir/Html/Form/validationErrors.en-uk.txt':[default]# this is a comment linegreeting = hello worldfoo = another language definitionnow add this code to your php script:require_once($APP['path']['core'] . 'util/Bs_LanguageHandler.class.php');$Bs_LanguageHandler =& new Bs_LanguageHandler();$t = &$Bs_LanguageHandler->determineLanguage('/some/dir/Html/Form/validationErrors', 'en-uk');if (is_null($t)) echo 'unknown error'; //yuck.list($lang, $path) = $t;$languageHash = &$Bs_LanguageHandler->readLanguage($path);echo $languageHash['default']['greeting'];now you have "hello world" on your screen.also see determineLanguage() to find out how to build your language files.dependencies: Bs_IniHandler

Authors
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_LanguageHandler()

Constructor
array

&readLanguage(string $path)

reads the given language file.
array

determineLanguage(string $path, [ string $lang ])

get the language that fits our needs.

Private Field Summary

array

$_APP

reference
object [unknown]

$_IniHandler

instance of class Bs_IniHandler

Private Constant Summary

BS_LANGUAGEHANDLER_VERSION >>4.0.$x$<< Warning: documentation is missing.

Public Method Details

Bs_LanguageHandler

public void Bs_LanguageHandler( )

  Constructor

Returns void


&readLanguage

public array &readLanguage( string $path )

  reads the given language file.

Parameter
string $path
the fullpath to the language file.
Returns array

a hash with the key/text values.
@throw NULL


determineLanguage

public array determineLanguage( string $path, [ string $lang ] )

  get the language that fits our needs.
if we are not absolutely sure if our language exist (and we are not), thenwe need to find out which one we can use.param $path:absolute path to the directory where the language files are. also include theunique base name of the lang files.example: you have these files/some/dir/errors.en-us.txt/some/dir/errors.en.txt/some/dir/errors.de.txt/some/dir/errors.fr.txtso your call would look like determineLanguage('/some/dir/errors', 'en-uk');which would load '/some/dir/errors.en.txt' (because en-uk does not exist).in this example the base name is "errors". the files have to end with '.txt'.

Parameter
string $path
(see above.)
string $lang = >>NULL<<
(if not set then the default lang (from $APP['usedLanguages']) will be used. if this fails, 'en' will be used.)
Returns array

(a vector with 2 elements. 1 = language, 2 = absolute path to language file.)

Throws NULL

Private Field Details

$_APP

private array $_APP

>><<

reference


$_IniHandler

private object [unknown] $_IniHandler

>><<

instance of class Bs_IniHandler


Private Constant Details

BS_LANGUAGEHANDLER_VERSION

define( BS_LANGUAGEHANDLER_VERSION, >>4.0.$x$<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta