summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php2
-rw-r--r--lib/files.php4
-rw-r--r--lib/json.php6
-rw-r--r--lib/l10n.php20
-rw-r--r--lib/template.php4
5 files changed, 28 insertions, 8 deletions
diff --git a/lib/app.php b/lib/app.php
index b499e1a8ef2..db2df7c2434 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -254,7 +254,7 @@ class OC_App{
* entries are sorted by the key 'order' ascending.
*/
public static function getSettingsNavigation(){
- $l=new OC_L10N('core');
+ $l=OC_L10N::get('core');
$settings = array();
// by default, settings only contain the help menu
diff --git a/lib/files.php b/lib/files.php
index 01558a68588..aacd2c9e004 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -225,7 +225,7 @@ class OC_Files {
*/
static function validateZipDownload($dir, $files) {
if(!OC_Config::getValue('allowZipDownload', true)) {
- $l = new OC_L10N('files');
+ $l = OC_L10N::get('files');
header("HTTP/1.0 409 Conflict");
$tmpl = new OC_Template( '', 'error', 'user' );
$errors = array(
@@ -250,7 +250,7 @@ class OC_Files {
$totalsize += OC_Filesystem::filesize($dir.'/'.$files);
}
if($totalsize > $zipLimit) {
- $l = new OC_L10N('files');
+ $l = OC_L10N::get('files');
header("HTTP/1.0 409 Conflict");
$tmpl = new OC_Template( '', 'error', 'user' );
$errors = array(
diff --git a/lib/json.php b/lib/json.php
index cedf79fd7c3..0d208ce12a2 100644
--- a/lib/json.php
+++ b/lib/json.php
@@ -24,7 +24,7 @@ class OC_JSON{
*/
public static function checkAppEnabled($app){
if( !OC_App::isEnabled($app)){
- $l = new OC_L10N('core');
+ $l = OC_L10N::get('core');
self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') )));
exit();
}
@@ -35,7 +35,7 @@ class OC_JSON{
*/
public static function checkLoggedIn(){
if( !OC_User::isLoggedIn()){
- $l = new OC_L10N('core');
+ $l = OC_L10N::get('core');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
}
@@ -47,7 +47,7 @@ class OC_JSON{
public static function checkAdminUser(){
self::checkLoggedIn();
if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
- $l = new OC_L10N('core');
+ $l = OC_L10N::get('core');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
}
diff --git a/lib/l10n.php b/lib/l10n.php
index 00bff08bf7f..c0ecdbd1b70 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -25,6 +25,11 @@
*/
class OC_L10N{
/**
+ * cached instances
+ */
+ protected static $instances=array();
+
+ /**
* cache
*/
protected static $cache = array();
@@ -46,6 +51,21 @@ class OC_L10N{
'date' => 'd.m.Y',
'datetime' => 'd.m.Y H:i:s',
'time' => 'H:i:s');
+
+ /**
+ * get an L10N instance
+ * @return OC_L10N
+ */
+ public static function get($app,$lang=null){
+ if(is_null($lang)){
+ if(!isset(self::$instances[$app])){
+ self::$instances[$app]=new OC_L10N($app);
+ }
+ return self::$instances[$app];
+ }else{
+ return new OC_L10N($app,$lang);
+ }
+ }
/**
* @brief The constructor
diff --git a/lib/template.php b/lib/template.php
index 5bcf52b9321..cb39a10df31 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -76,7 +76,7 @@ function simple_file_size($bytes) {
}
function relative_modified_date($timestamp) {
- $l=new OC_L10N('template');
+ $l=OC_L10N::get('template');
$timediff = time() - $timestamp;
$diffminutes = round($timediff/60);
$diffhours = round($diffminutes/60);
@@ -155,7 +155,7 @@ class OC_Template{
$this->renderas = $renderas;
$this->application = $app;
$this->vars = array();
- $this->l10n = new OC_L10N($app);
+ $this->l10n = OC_L10N::get($app);
$this->findTemplate($name);
}