string.php 633 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. class OC_L10N_String{
  9. protected $l10n;
  10. public function __construct($l10n, $text, $parameters){
  11. $this->l10n = $l10n;
  12. $this->text = $text;
  13. $this->parameters = $parameters;
  14. }
  15. public function __toString(){
  16. $translations = $this->l10n->getTranslations();
  17. if(array_key_exists($this->text, $translations)){
  18. return vsprintf($translations[$this->text], $this->parameters);
  19. }
  20. return vsprintf($this->text, $this->parameters);
  21. }
  22. }