Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 163 additions & 163 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This directory contains example code covering various aspect of h2o template.

Simple
=====================
A simple template displaying a list of users, it demonstrate
A simple template displaying a list of users, it demonstrate

- how to setup h2o template and pass view variables to template
- display variables and using build-in tags and filters
Expand Down Expand Up @@ -33,11 +33,11 @@ Demonstrates

- how to use different cache driver
- bundled cache extension to provide fragment cache to speed up resource intensive operations
such as loading complex logic from database
such as loading complex logic from database

I18n
=====================
Demo to show how to build a internationalized template with h2o by displaying a template
Demo to show how to build a internationalized template with h2o by displaying a template
supporting three languages.

I18n extension also bundled message extraction class to extract translatable strings into
Expand Down
52 changes: 26 additions & 26 deletions example/caching/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//// Set language to German

//$i18n = new H2o_I18n(dirname(__FILE__).DS, array(
// 'gettext_path' => dirname(__FILE__).DS.'bin/gettext/bin/'
// 'gettext_path' => dirname(__FILE__).DS.'bin/gettext/bin/'
//));
//$i18n->setLocale('fr');
//
Expand All @@ -14,40 +14,40 @@
////
// Choose domain
//extract_translations(
// realpath('trans.tpl'), array('tpl', 'html'), dirname(__FILE__).DS.'bin/gettext/bin/'
// realpath('trans.tpl'), array('tpl', 'html'), dirname(__FILE__).DS.'bin/gettext/bin/'
//);
//
//compile_translations(
// realpath('trans.tpl'), null, dirname(__FILE__).DS.'bin/gettext/bin/'
// realpath('trans.tpl'), null, dirname(__FILE__).DS.'bin/gettext/bin/'
//);
$template = new H2o('trans.tpl', array('cache'=> false, 'cache_dir' => dirname(__FILE__)));
$time_start = microtime(true);

for($i=0; $i<10; $i++)
$r = $template->render(array(
'users' => array(
array(
'username' => 'peter',
'tasks' => array('school', 'writing'),
'user_id' => 1,
),
array(
'username' => 'anton',
'tasks' => array('go shopping'),
'user_id' => 2,
),
array(
'username' => 'john doe',
'tasks' => array('write report', 'call tony', 'meeting with arron'),
'user_id' => 3
),
array(
'username' => 'foobar',
'tasks' => array(),
'user_id' => 4
)
)
'users' => array(
array(
'username' => 'peter',
'tasks' => array('school', 'writing'),
'user_id' => 1,
),
array(
'username' => 'anton',
'tasks' => array('go shopping'),
'user_id' => 2,
),
array(
'username' => 'john doe',
'tasks' => array('write report', 'call tony', 'meeting with arron'),
'user_id' => 3
),
array(
'username' => 'foobar',
'tasks' => array(),
'user_id' => 4
)
)
));
echo $r;

Expand Down
6 changes: 3 additions & 3 deletions example/extensions/ext/site_tags.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

class Site_Tag extends Tag {
function render($context, $stream) {
$stream->write('This is my site');
}
function render($context, $stream) {
$stream->write('This is my site');
}
}


Expand Down
60 changes: 30 additions & 30 deletions example/i18n/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
require '../../h2o.php';

$template = new H2o('trans.html', array(
'cache'=> false,
'i18n' => array(
'locale' => isset($_GET['lang']) ? $_GET['lang'] : false,
'charset' => 'UTF-8',
'gettext_path' => '../bin/gettext/bin/',
'extract_message' => true,
'compile_message' => true,
)
'cache'=> false,
'i18n' => array(
'locale' => isset($_GET['lang']) ? $_GET['lang'] : false,
'charset' => 'UTF-8',
'gettext_path' => '../bin/gettext/bin/',
'extract_message' => true,
'compile_message' => true,
)
));

# Setup custom gettext resolver
Expand All @@ -18,28 +18,28 @@
$time_start = microtime(true);

echo $template->render(array(
'users' => array(
array(
'username' => 'peter',
'tasks' => array('school', 'writing'),
'user_id' => 1,
),
array(
'username' => 'anton',
'tasks' => array('go shopping'),
'user_id' => 2,
),
array(
'username' => 'john doe',
'tasks' => array('write report', 'call tony', 'meeting with arron'),
'user_id' => 3
),
array(
'username' => 'foobar',
'tasks' => array(),
'user_id' => 4
)
)
'users' => array(
array(
'username' => 'peter',
'tasks' => array('school', 'writing'),
'user_id' => 1,
),
array(
'username' => 'anton',
'tasks' => array('go shopping'),
'user_id' => 2,
),
array(
'username' => 'john doe',
'tasks' => array('write report', 'call tony', 'meeting with arron'),
'user_id' => 3
),
array(
'username' => 'foobar',
'tasks' => array(),
'user_id' => 4
)
)
));
echo "in ".(microtime(true) - $time_start)." seconds\n<br/>";

Expand Down
28 changes: 14 additions & 14 deletions example/i18n/locale/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,44 @@ msgid "Finish"
msgstr "Fertig stellen"

msgid ""
" (software engineering) The act or process of making a product suitable "
" (software engineering) The act or process of making a product suitable "
"for \n"
" international markets, typically by making text messages easily "
" international markets, typically by making text messages easily "
"translatable \n"
" and ensuring support of non-Latin character sets.\n"
" and ensuring support of non-Latin character sets.\n"
msgstr ""
" (Software Engineering) Die Handlung oder Verfahren zur Herstellung "
" (Software Engineering) Die Handlung oder Verfahren zur Herstellung "
"eines Produktes geeignet für \n"
" internationalen Märkten, die in der Regel durch das Erstellen von Text-"
" internationalen Märkten, die in der Regel durch das Erstellen von Text-"
"Nachrichten leicht zu vermitteln \n"
" und die Gewährleistung von Unterstützung von nicht-lateinischen "
" und die Gewährleistung von Unterstützung von nicht-lateinischen "
"Zeichensätzen. \n"

msgid "Pluralization support"
msgstr "Pluralisierung Unterstützung"

msgid ""
"\t there is one %(count) item.\n"
"\t there is one %(count) item.\n"
"\t"
msgid_plural ""
"\t there are number of %(count) items.\n"
"\t there are number of %(count) items.\n"
"\t"
msgstr[0] ""
"\t gibt es ein %(count) Posten.\n"
"\t gibt es ein %(count) Posten.\n"
"\t"
msgstr[1] ""
"\t Es gibt einige %(count) Elemente.\n"
"\t Es gibt einige %(count) Elemente.\n"
"\t"

msgid ""
"\t\t %(name) has %(count) task\n"
"\t\t %(name) has %(count) task\n"
"\t\t"
msgid_plural ""
"\t\t %(name) has %(count) tasks\n"
"\t\t %(name) has %(count) tasks\n"
"\t\t"
msgstr[0] ""
"\t\t %(name) hat %(count) Aufgabe\n"
"\t\t %(name) hat %(count) Aufgabe\n"
"\t\t"
msgstr[1] ""
"\t\t %(name) hat %(count) Aufgaben \n"
"\t\t %(name) hat %(count) Aufgaben \n"
"\t\t"
26 changes: 13 additions & 13 deletions example/i18n/locale/fi/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,42 @@ msgid "Finish"
msgstr "Maali"

msgid ""
" (software engineering) The act or process of making a product suitable "
" (software engineering) The act or process of making a product suitable "
"for \n"
" international markets, typically by making text messages easily "
" international markets, typically by making text messages easily "
"translatable \n"
" and ensuring support of non-Latin character sets.\n"
" and ensuring support of non-Latin character sets.\n"
msgstr ""
"(Software Engineering) Lakia tai prosessin tehdä tuote soveltuu \n"
" kansainvälisillä markkinoilla, tyypillisesti tekemällä tekstiviestejä "
" kansainvälisillä markkinoilla, tyypillisesti tekemällä tekstiviestejä "
"helposti käännettävissä \n"
" ja varmistamaan tuki ei-latinalaisia merkistöjä. \n"
" ja varmistamaan tuki ei-latinalaisia merkistöjä. \n"

msgid "Pluralization support"
msgstr "Pluralization tukea"

msgid ""
"\t there is one %(count) item.\n"
"\t there is one %(count) item.\n"
"\t"
msgid_plural ""
"\t there are number of %(count) items.\n"
"\t there are number of %(count) items.\n"
"\t"
msgstr[0] ""
"\t on yksi %(count) erä.\n"
"\t on yksi %(count) erä.\n"
"\t"
msgstr[1] ""
"\t on olemassa joukko %(count) kohteita.\n"
"\t on olemassa joukko %(count) kohteita.\n"
"\t"

msgid ""
"\t\t %(name) has %(count) task\n"
"\t\t %(name) has %(count) task\n"
"\t\t"
msgid_plural ""
"\t\t %(name) has %(count) tasks\n"
"\t\t %(name) has %(count) tasks\n"
"\t\t"
msgstr[0] ""
"\t\t %(name) on %(count) tehtävä \n"
"\t\t %(name) on %(count) tehtävä \n"
"\t\t"
msgstr[1] ""
"\t\t %(name) on %(count) tehtävät\n"
"\t\t %(name) on %(count) tehtävät\n"
"\t\t"
34 changes: 17 additions & 17 deletions example/i18n/locale/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,51 @@ msgid "Finish"
msgstr "Terminer"

msgid ""
" (software engineering) The act or process of making a product suitable "
" (software engineering) The act or process of making a product suitable "
"for \n"
" international markets, typically by making text messages easily "
" international markets, typically by making text messages easily "
"translatable \n"
" and ensuring support of non-Latin character sets.\n"
" and ensuring support of non-Latin character sets.\n"
msgstr ""
" (génie logiciel) L'acte ou processus de fabrication d'un produit adapté "
" (génie logiciel) L'acte ou processus de fabrication d'un produit adapté "
"à \n"
" les marchés internationaux, généralement en faisant des messages texte "
" les marchés internationaux, généralement en faisant des messages texte "
"facilement traduisible \n"
" et d'assurer le soutien de la non-latino-jeux de caractères. \n"
" \n"
" et d'assurer le soutien de la non-latino-jeux de caractères. \n"
" \n"

msgid "Pluralization support"
msgstr "Pluralisation de soutien"

msgid ""
"\t there is one %(count) item.\n"
"\t there is one %(count) item.\n"
"\t"
msgid_plural ""
"\t there are number of %(count) items.\n"
"\t there are number of %(count) items.\n"
"\t"
msgstr[0] ""
"\t il ya un %(count) point.\n"
"\t il ya un %(count) point.\n"
"\t"
msgstr[1] ""
"\t Il existe un certain nombre de %(count) points. \n"
"\t Il existe un certain nombre de %(count) points. \n"
"\t"

msgid ""
"\t\t %(name) has %(count) task\n"
"\t\t %(name) has %(count) task\n"
"\t\t"
msgid_plural ""
"\t\t %(name) has %(count) tasks\n"
"\t\t %(name) has %(count) tasks\n"
"\t\t"
msgstr[0] ""
"\t\t %(name) a %(count) tâche \n"
"\t\t %(name) a %(count) tâche \n"
"\t\t"
msgstr[1] ""
"\t\t %(name) a %(count) tâches \n"
"\t\t %(name) a %(count) tâches \n"
"\t\t"

# C:\workspace\h2o\example\i18n\trans.html:7
#~ msgid " (software engineering)\n"
#~ msgstr " (software engineering fr)\n"
#~ msgid " (software engineering)\n"
#~ msgstr " (software engineering fr)\n"

#~ msgid "Insert title here"
#~ msgstr "Insérer le titre ici"
Expand Down
Loading