diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-18 21:16:51 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-18 23:07:32 +0200 |
commit | d4044d0283147df678dc0f833abfcc844e0eff75 (patch) | |
tree | 2add184ef4b47c14e158f117a0fe8314a8f5fed8 /lib/l10n/string.php | |
parent | a1364c9726b1511a193ced8dac00e44d5515437b (diff) | |
download | nextcloud-server-d4044d0283147df678dc0f833abfcc844e0eff75.tar.gz nextcloud-server-d4044d0283147df678dc0f833abfcc844e0eff75.zip |
Delay loading of translations until they are used
Diffstat (limited to 'lib/l10n/string.php')
-rw-r--r-- | lib/l10n/string.php | 25 |
1 files changed, 25 insertions, 0 deletions
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 @@ +<?php +/** + * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> + * 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); + } +} |