cvs: peardoc /en/package/internationalization/translation2 intro-containers.xml

From: Date: Tue, 16 Nov 2004 20:09:30 +0000
Subject: cvs: peardoc /en/package/internationalization/translation2 intro-containers.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-5125@lists.php.net to get a copy of this message
mike Tue Nov 16 15:09:30 2004 EDT Modified files: /peardoc/en/package/internationalization/translation2 intro-containers.xml Log: * update gettext section http://cvs.php.net/diff.php/peardoc/en/package/internationalization/translation2/intro-containers.xml?r1=1.6&r2=1.7&ty=u Index: peardoc/en/package/internationalization/translation2/intro-containers.xml diff -u peardoc/en/package/internationalization/translation2/intro-containers.xml:1.6 peardoc/en/package/internationalization/translation2/intro-containers.xml:1.7 --- peardoc/en/package/internationalization/translation2/intro-containers.xml:1.6 Tue Nov 16 14:32:12 2004 +++ peardoc/en/package/internationalization/translation2/intro-containers.xml Tue Nov 16 15:09:27 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry id="package.internationalization.translation2.intro-containers"> <refnamediv> <refname>Containers Overview</refname> @@ -107,29 +107,30 @@ </para> <para> - The connection parameters are a bit different from the db ones. + The construction parameters are a bit different from the db ones. To make things as simple as possible, the domain definitions and the - available language list are read from two .ini files. - + available language list are read from two INI files. + </para> + + <para> langs.ini example: <programlisting> <![CDATA[ + +; If one does not specify the source encoding, ISO-8859-1 is assumed +; Beware that gettext can choke on bad encodings! + [en] name = English -error_text = not available in English -windows = enu encoding = iso-8859-1 [de] name = Deutsch encoding = iso-8859-1 -windows = deu [it] name = italiano encoding = iso-8859-1 -error_text = non disponibile in italiano -windows = ita ]]> </programlisting> @@ -155,10 +156,16 @@ 'default_domain' => 'messages', ); -$tr =& Translation2::factory('gettext', null, $params); +// Better set prefetch to FALSE for the gettext container, so we don't need +// to read in the whole MO file with File_Gettext on every request. +$tr =& Translation2::factory('gettext', array('prefetch' => false), $params); $tr->setLang('en'); + +// Note that, if there is no translation available for a string, the gettext +// container will return the string ID! This behaviour emulates native gettext. echo $tr->get('mystring'); + print_r($tr->getPage('3rddomain')); ]]> </programlisting>

« previous php.pear.doc (#5125) next »