Author: Derick Rethans
Date: 2006-01-25 20:38:53 +0100 (Wed, 25 Jan 2006)
New Revision: 2035

Log:
- Added the filters part to the turorial.

Added:
   packages/Translation/trunk/docs/tutorial_example_03.php
   packages/Translation/trunk/docs/tutorial_example_03b.php
Modified:
   packages/Translation/trunk/docs/tutorial.txt

Modified: packages/Translation/trunk/docs/tutorial.txt
===================================================================
--- packages/Translation/trunk/docs/tutorial.txt        2006-01-25 19:15:06 UTC 
(rev 2034)
+++ packages/Translation/trunk/docs/tutorial.txt        2006-01-25 19:38:53 UTC 
(rev 2035)
@@ -146,6 +146,51 @@
 .. _ISO3166: 
http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
 
 
+Filters
+=======
+
+In some cases not all the translation files are up to date. For example the
+original translation file was updated with new strings, but your translator had
+no time to translate the strings yet. For your application to show atleast the
+original strings (often English) the Translation component offers filters.
+Filters are applied after the backend retrieved the data, but before it is 
placed
+in the internal cache of the manager. 
+
+.. include:: tutorial_example_03.php
+   :literal:
+
+In this example we add a filter to the manager which we create in line 8. In
+line 9 we then request translation for a string that is marked as "unfinished".
+The Complement Empty Filter fills in the original string for every translation
+that is still marked as "unfinished" and your application shows the original
+language's text.
+
+There are a few extra (less useful) filters in the Translation component as
+well. The next example shows the "Leet" and "Bork" filters in action. The Bork
+filter mangles non-finished or non-translated text so that it is obvious which
+text is translatable, but not yet translated. The "Leet" filter renders your
+text using Leetspeak_. Both filters are demonstrated in the following example:
+
+.. include:: tutorial_example_03b.php
+   :literal:
+
+Lines 4 to 8 show the usage of the ezcTranslationBorkFilter and lines 10 to 14
+the usage of the ezcTranslationLeetFilter. The output of this script is: ::
+
+    header1
+    [Seerch for 'appelmoes' retoorned 4 metches.]
+    3r zijn 4 i73ms g3v0nd3n bij h37 z03k3n n44r 'appelmoes'.
+
+The first line is "header1" because this script includes the previous one. For
+the Bork filter you can see that it uses the original string and not the
+translated version. The Leet filter however uses the translated string
+exclusively. In case you want to implement your own filters, you need to create
+a class that implements the ezcTranslationFilter interface. Have a look at the
+implementation for the ezcTranslationBorkFilter filter, which shows how to
+implement such a class.
+
+.. _Leetspeak: http://en.wikipedia.org/wiki/Leet
+
 Iteration
 =========
 

Added: packages/Translation/trunk/docs/tutorial_example_03.php
===================================================================
--- packages/Translation/trunk/docs/tutorial_example_03.php     2006-01-25 
19:15:06 UTC (rev 2034)
+++ packages/Translation/trunk/docs/tutorial_example_03.php     2006-01-25 
19:38:53 UTC (rev 2035)
@@ -0,0 +1,11 @@
+<?php
+require_once 'tutorial_autoload.php';
+
+$backend = new ezcTranslationTsBackend( dirname( __FILE__ ). '/translations' );
+$backend->setOptions( array( 'format' => 'translation-[LOCALE].xml' ) );
+
+$manager = new ezcTranslationManager( $backend );
+$manager->addFilter( ezcTranslationComplementEmptyFilter::getInstance() );
+$headersContext = $manager->getContext( 'nl_NL', 'tutorial/headers' );
+echo $headersContext->getTranslation( 'header1' ), "\n";
+?>


Property changes on: packages/Translation/trunk/docs/tutorial_example_03.php
___________________________________________________________________
Name: svn:eol-style
   + native

Added: packages/Translation/trunk/docs/tutorial_example_03b.php
===================================================================
--- packages/Translation/trunk/docs/tutorial_example_03b.php    2006-01-25 
19:15:06 UTC (rev 2034)
+++ packages/Translation/trunk/docs/tutorial_example_03b.php    2006-01-25 
19:38:53 UTC (rev 2035)
@@ -0,0 +1,15 @@
+<?php
+require_once 'tutorial_example_03.php';
+
+$manager = new ezcTranslationManager( $backend );
+$manager->addFilter( ezcTranslationBorkFilter::getInstance() );
+$search = $manager->getContext( 'nl_NL', 'search' );
+$params = array( 'search_string' => 'appelmoes', 'matches' => 4 );
+echo $search->getTranslation( "Search for '%search_string' returned %matches 
matches.", $params ), "\n";
+
+$manager = new ezcTranslationManager( $backend );
+$manager->addFilter( ezcTranslationLeetFilter::getInstance() );
+$search = $manager->getContext( 'nl_NL', 'search' );
+$params = array( 'search_string' => 'appelmoes', 'matches' => 4 );
+echo $search->getTranslation( "Search for '%search_string' returned %matches 
matches.", $params ), "\n";
+?>


Property changes on: packages/Translation/trunk/docs/tutorial_example_03b.php
___________________________________________________________________
Name: svn:eol-style
   + native

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to