2013-09-25 16:34:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Bart Visscher <bartv@thisnet.nl>
|
2015-10-05 18:54:56 +00:00
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Robin Appelman <icewind@owncloud.com>
|
|
|
|
* @author Robin McCorkell <rmccorkell@karoshi.org.uk>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2013-09-25 16:34:01 +00:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2013-09-25 16:34:01 +00:00
|
|
|
namespace OC\L10N;
|
|
|
|
|
2015-08-27 11:14:50 +00:00
|
|
|
use OCP\L10N\IFactory;
|
|
|
|
|
2013-09-25 16:34:01 +00:00
|
|
|
/**
|
2015-08-27 11:14:50 +00:00
|
|
|
* A factory that generates language instances
|
2013-09-25 16:34:01 +00:00
|
|
|
*/
|
2015-08-27 11:14:50 +00:00
|
|
|
class Factory implements IFactory {
|
2013-09-25 16:34:01 +00:00
|
|
|
/**
|
|
|
|
* cached instances
|
|
|
|
*/
|
|
|
|
protected $instances = array();
|
|
|
|
|
|
|
|
/**
|
2015-08-27 11:14:50 +00:00
|
|
|
* Get a language instance
|
2014-08-31 08:05:59 +00:00
|
|
|
*
|
2014-05-11 20:51:30 +00:00
|
|
|
* @param string $app
|
|
|
|
* @param string|null $lang
|
2015-08-27 11:14:50 +00:00
|
|
|
* @return \OCP\IL10N
|
2013-09-25 16:34:01 +00:00
|
|
|
*/
|
2014-08-31 08:05:59 +00:00
|
|
|
public function get($app, $lang = null) {
|
2015-08-27 11:14:50 +00:00
|
|
|
$key = $lang;
|
|
|
|
if ($key === null) {
|
|
|
|
$key = 'null';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($this->instances[$key][$app])) {
|
|
|
|
$this->instances[$key][$app] = new \OC_L10N($app, $lang);
|
2013-09-25 16:34:01 +00:00
|
|
|
}
|
2015-08-27 11:14:50 +00:00
|
|
|
|
|
|
|
return $this->instances[$key][$app];
|
2013-09-25 16:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|