===== BASIC DOCUMENTATION FOR MSGCAT Multi Language class v 1.0 =====
0.- INTRODUCTION
This class is designed as a message catalog (just like in TCL or other
scripting tools). Builds an array of translations for string identifiers
and can be quite useful to deploy multiple language versions of the same
scripts. NOTE IT STORES FULL MSG CATALOG ON MEMORY, DO NOT USE ON HEAVY
TRANSLATION ENVIRONMENT
1.- INTERFACE
The public interface for the class is formed by:
msgcat($localstr,$loaddir="./",$debug=0)
CONSTRUCTOR: Initializes catalog
$localstr -> locale string identifier, used to determine translation
file and msg validation
$loaddir -> full path from current path to find *.msg files for the class
$debug -> Debug level: 0-none; 1- <!-- --> echo; 2 - file 'debug' in $loaddir
mc($srcstr)
TRANSLATOR: Returns (string) translation for $srcstr for current locale
$srcstr -> identifier to translate
destroy()
DESTRUCTOR; Close file operations and such
2.- MSG CATALOG FILES
Each locale must have a file named [locale].msg to be used
i.e. ENGLISH msg cataloc should be en.msg
File contents will be as follows:
[locale]#:#[identifier]#:#[translation]\n
i.e. en#:#WM#:#Greetings, wellcome to my site
en#:#CM#:#Come back soon!
Comments can be added to the file on a line starting with '//'
i.e. // General Messages
en#:#MSG1#:#Test message 1
//Section names
en#:#SECT1#:#File Archives
en#:#SECT2#:#New entries
3.- CODING EXAMPLE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php require("msgcat_class.php") ; ?>
<html>
<head>
<title>MSGCAT test</title>
</head>
<body>
<?php
$msg = new msgcat("en") ;
echo $msg->mc("WM") ;
$msg->destroy() ;
?>
</body>
</html>
This will output (based on the en.msg file from section 2 ex. 1)
Greetings, wellcome to my site
4.- Future releases and WIP
This class will not have many revisions as it is fully functional for
it's intended use. For furtehr developement any suggestions are wellcome
3.- Contact information
Carlos Falo Hervás
carles@bisinteractive.net
http://www.bisinteractive.net
C/Manila 54-56 Esc. A Ent. 4ª
08034 Barcelona Spain
Phone: +34 9 3 2063652
Fax: +34 9 3 2063689
|