From d4044d0283147df678dc0f833abfcc844e0eff75 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 18 Jun 2012 21:16:51 +0200 Subject: Delay loading of translations until they are used --- lib/l10n/string.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/l10n/string.php (limited to 'lib/l10n') diff --git a/lib/l10n/string.php b/lib/l10n/string.php new file mode 100644 index 00000000000..4769790a16d --- /dev/null +++ b/lib/l10n/string.php @@ -0,0 +1,25 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class OC_L10N_String{ + protected $l10n; + public function __construct($l10n, $text, $parameters){ + $this->l10n = $l10n; + $this->text = $text; + $this->parameters = $parameters; + + } + + public function __toString(){ + $translations = $this->l10n->getTranslations(); + if(array_key_exists($this->text, $translations)){ + return vsprintf($translations[$this->text], $this->parameters); + } + return vsprintf($this->text, $this->parameters); + } +} -- cgit v1.2.3