Skip to content

Commit

Permalink
translation
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed May 11, 2011
1 parent 46600aa commit 4a661bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
silex.phar
vendor
33 changes: 33 additions & 0 deletions translation/index.php
@@ -0,0 +1,33 @@
<?php

require __DIR__.'/silex.phar';

$app = new Silex\Application();

$app->register(new Silex\Extension\TranslationExtension(), array(
'translation.class_path' => __DIR__.'/vendor',
));

$app['translator.messages'] = array(
'en' => array(
'hello' => 'Hello %s',
),
'de' => array(
'hello' => 'Hallo %s',
),
'fr' => array(
'hello' => 'Salut %s',
),
);

$app->before(function () use ($app) {
if ($locale = $app['request']->get('locale')) {
$app['locale'] = $locale;
}
});

$app->match('/{locale}/hello/{name}', function ($name) use ($app) {
return sprintf($app['translator']->trans('hello'), $name);
});

$app->run();
2 changes: 2 additions & 0 deletions translation/vendors.sh
@@ -0,0 +1,2 @@
#!/bin/sh
git clone https://github.com/symfony/Translation.git vendor/Symfony/Component/Translation

0 comments on commit 4a661bb

Please sign in to comment.