I18n.php 482 B

1234567891011121314151617181920
  1. <?php
  2. class I18n extends Mustache {
  3. // Variable to be interpolated
  4. public $name = 'Bob';
  5. // Add a {{#__}} lambda for i18n
  6. public $__ = array(__CLASS__, '__trans');
  7. // A *very* small i18n dictionary :)
  8. private $dictionary = array(
  9. 'Hello.' => 'Hola.',
  10. 'My name is {{ name }}.' => 'Me llamo {{ name }}.',
  11. );
  12. public function __trans($text) {
  13. return isset($this->dictionary[$text]) ? $this->dictionary[$text] : $text;
  14. }
  15. }