From 4ea0d3c05d374040377fdf7302e3fe23b98d7342 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Jan 2016 12:57:50 +0100 Subject: [PATCH] Deprecate getFirstWeekDay() and getDateFormat() in favor of l() --- core/js/config.php | 4 ++-- lib/private/l10n.php | 34 ++++++++++------------------------ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/core/js/config.php b/core/js/config.php index 0670df60abd..708da777ee4 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -67,7 +67,7 @@ $array = array( "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false', "oc_webroot" => "\"".OC::$WEBROOT."\"", "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution - "datepickerFormatDate" => json_encode($l->getDateFormat()), + "datepickerFormatDate" => json_encode($l->l('jsdate', null)), "dayNames" => json_encode( array( (string)$l->t('Sunday'), @@ -133,7 +133,7 @@ $array = array( (string)$l->t('Dec.') ) ), - "firstDay" => json_encode($l->getFirstWeekDay()) , + "firstDay" => json_encode($l->l('firstday', null)) , "oc_config" => json_encode( array( 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), diff --git a/lib/private/l10n.php b/lib/private/l10n.php index 5a704916f40..2ad93c8c90b 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -226,6 +226,8 @@ class OC_L10N implements \OCP\IL10N { * - time * - Creates a time * - params: timestamp (int/string) + * - firstday: Returns the first day of the week (0 sunday - 6 saturday) + * - jsdate: Returns the short JS date format */ public function l($type, $data, $options = array()) { if ($type === 'firstday') { @@ -272,45 +274,29 @@ class OC_L10N implements \OCP\IL10N { return $this->lang; } - /** - * find the l10n directory - * @param string $app App that needs to be translated - * @return string directory - */ - protected function findI18nDir($app) { - // find the i18n dir - $i18nDir = OC::$SERVERROOT.'/core/l10n/'; - if($app != '') { - // Check if the app is in the app folder - if(file_exists(OC_App::getAppPath($app).'/l10n/')) { - $i18nDir = OC_App::getAppPath($app).'/l10n/'; - } - else{ - $i18nDir = OC::$SERVERROOT.'/'.$app.'/l10n/'; - } - } - return $i18nDir; - } - /** * @return string * @throws \Punic\Exception\ValueNotInList + * @deprecated 9.0.0 Use $this->l('jsdate', null) instead */ public function getDateFormat() { - $locale = $this->getLanguageCode(); - $locale = $this->transformToCLDRLocale($locale); + $locale = $this->transformToCLDRLocale($this->getLanguageCode()); return Punic\Calendar::getDateFormat('short', $locale); } /** * @return int + * @deprecated 9.0.0 Use $this->l('firstday', null) instead */ public function getFirstWeekDay() { - $locale = $this->getLanguageCode(); - $locale = $this->transformToCLDRLocale($locale); + $locale = $this->transformToCLDRLocale($this->getLanguageCode()); return Punic\Calendar::getFirstWeekday($locale); } + /** + * @param string $locale + * @return string + */ private function transformToCLDRLocale($locale) { if ($locale === 'sr@latin') { return 'sr_latn'; -- 2.39.5