webforge/translation

Translation component based on symfony/translation

1.0.4 2013-11-04 06:24 UTC

README

Coverage Status

Wrapper around the symfony translator for standalone use

installation

Use Composer to install.

composer require -v --prefer-source webforge/translation:dev-master

to run the tests use:

phpunit

usage

<?php

use Webforge\Translation\ArrayTranslator;

$translations = Array(
  'de'=>Array(
    'hello'=>'Hallo Welt!'
  ),

  'en'=>Array(
    'hello'=>'Hello World!',
    'how'=>'How are you?'
  ),
);

$translator = new ArrayTranslator('de', $translations, $fallback = array('en'));

print $translator->trans('hello')."\n"; // Hallo Welt!
print $translator->trans('how')."\n"; // How are you?

$translator->setLocale('en');
print $translator->trans('hello')."\n"; // Hello World!

dependencies

  • symfony/translation 2.3