Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ZurmoLocale.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
42  class ZurmoLocale extends CLocale
43  {
49  public static $dataPath;
50 
51  private $_id;
52  private $_data;
53  private $_dateFormatter;
54  private $_numberFormatter;
55 
63  public static function getInstance($id)
64  {
65  static $locales = array();
66  if (isset($locales[$id]))
67  {
68  return $locales[$id];
69  }
70  else
71  {
72  return $locales[$id] = new ZurmoLocale($id);
73  }
74  }
75 
79  public static function getLocaleIDs()
80  {
81  static $locales;
82  if ($locales === null)
83  {
84  $locales = array();
85  $dataPath = self::$dataPath === null ? YII_PATH . DIRECTORY_SEPARATOR . 'i18n'.DIRECTORY_SEPARATOR . 'data' : self::$dataPath;
86  $folder = @opendir($dataPath);
87  while (($file = @readdir($folder)) !== false)
88  {
89  $fullPath = $dataPath . DIRECTORY_SEPARATOR . $file;
90  if (substr($file, -4) ==='.php' && is_file($fullPath))
91  {
92  $locales[] = substr($file, 0, -4);
93  }
94  }
95  closedir($folder);
96  sort($locales);
97  }
98  return $locales;
99  }
100 
106  public static function getSelectableLocaleIds()
107  {
108  return array('de_de', 'en_au', 'en_ca', 'en_gb', 'en_us', 'es_es', 'fr_fr', 'it_it', 'nl_nl');
109  }
110 
117  protected function __construct($id)
118  {
119  $this->_id = self::getCanonicalID($id);
120  $dataPath = self::$dataPath === null ? YII_PATH . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . 'data' : self::$dataPath;
121  $dataFile = $dataPath . DIRECTORY_SEPARATOR . $this->_id . '.php';
122  if (is_file($dataFile))
123  {
124  $this->_data = require($dataFile);
125  }
126  else
127  {
128  throw new CException(Zurmo::t('yii', 'Unrecognized locale "{locale}".', array('{locale}' => $id)));
129  }
130  }
131 
135  public function getId()
136  {
137  return $this->_id;
138  }
139 
143  public function getNumberFormatter()
144  {
145  if ($this->_numberFormatter === null)
146  {
147  $this->_numberFormatter = new CNumberFormatter($this);
148  }
149  return $this->_numberFormatter;
150  }
151 
155  public function getDateFormatter()
156  {
157  if ($this->_dateFormatter === null)
158  {
159  $this->_dateFormatter = new CDateFormatter($this);
160  }
161  return $this->_dateFormatter;
162  }
163 
168  public function getCurrencySymbol($currency)
169  {
170  return isset($this->_data['currencySymbols'][$currency]) ? $this->_data['currencySymbols'][$currency] : null;
171  }
172 
177  public function getNumberSymbol($name)
178  {
179  return isset($this->_data['numberSymbols'][$name]) ? $this->_data['numberSymbols'][$name] : null;
180  }
181 
185  public function getDecimalFormat()
186  {
187  return $this->_data['decimalFormat'];
188  }
189 
193  public function getCurrencyFormat()
194  {
195  return $this->_data['currencyFormat'];
196  }
197 
201  public function getPercentFormat()
202  {
203  return $this->_data['percentFormat'];
204  }
205 
209  public function getScientificFormat()
210  {
211  return $this->_data['scientificFormat'];
212  }
213 
220  public function getMonthName($month, $width = 'wide', $standAlone = false)
221  {
222  if ($standAlone)
223  {
224  return isset($this->_data['monthNamesSA'][$width][$month]) ? $this->_data['monthNamesSA'][$width][$month] : $this->_data['monthNames'][$width][$month];
225  }
226  else
227  {
228  return isset($this->_data['monthNames'][$width][$month]) ? $this->_data['monthNames'][$width][$month] : $this->_data['monthNamesSA'][$width][$month];
229  }
230  }
231 
238  public function getMonthNames($width = 'wide', $standAlone = false)
239  {
240  if ($standAlone)
241  {
242  return isset($this->_data['monthNamesSA'][$width]) ? $this->_data['monthNamesSA'][$width] : $this->_data['monthNames'][$width];
243  }
244  else
245  {
246  return isset($this->_data['monthNames'][$width]) ? $this->_data['monthNames'][$width] : $this->_data['monthNamesSA'][$width];
247  }
248  }
249 
256  public function getWeekDayName($day, $width = 'wide', $standAlone = false)
257  {
258  if ($standAlone)
259  {
260  return isset($this->_data['weekDayNamesSA'][$width][$day]) ? $this->_data['weekDayNamesSA'][$width][$day] : $this->_data['weekDayNames'][$width][$day];
261  }
262  else
263  {
264  return isset($this->_data['weekDayNames'][$width][$day]) ? $this->_data['weekDayNames'][$width][$day] : $this->_data['weekDayNamesSA'][$width][$day];
265  }
266  }
267 
274  public function getWeekDayNames($width = 'wide', $standAlone = false)
275  {
276  if ($standAlone)
277  {
278  return isset($this->_data['weekDayNamesSA'][$width]) ? $this->_data['weekDayNamesSA'][$width] : $this->_data['weekDayNames'][$width];
279  }
280  else
281  {
282  return isset($this->_data['weekDayNames'][$width]) ? $this->_data['weekDayNames'][$width] : $this->_data['weekDayNamesSA'][$width];
283  }
284  }
285 
291  public function getEraName($era, $width = 'wide')
292  {
293  return $this->_data['eraNames'][$width][$era];
294  }
295 
299  public function getAMName()
300  {
301  return $this->_data['amName'];
302  }
303 
307  public function getPMName()
308  {
309  return $this->_data['pmName'];
310  }
311 
316  public function getDateFormat($width = 'medium')
317  {
318  return $this->_data['dateFormats'][$width];
319  }
320 
325  public function getDateFormatForInput($width = 'medium')
326  {
327  $dateFormat = $this->getDateFormat($width);
328  if (strpos($dateFormat, 'yy') !== false && strpos($dateFormat, 'yyyy') === false)
329  {
330  $dateFormat = str_replace('yy', 'yyyy', $dateFormat);
331  }
332  return $dateFormat;
333  }
334 
339  public function getTimeFormat($width = 'medium')
340  {
341  return $this->_data['timeFormats'][$width];
342  }
343 
347  public function getDateTimeFormat()
348  {
349  if (in_array($this->_id, array('zn_ch')))
350  {
351  return '{1} {0}';
352  }
353  return $this->_data['dateTimeFormat'];
354  }
355 
360  public function getOrientation()
361  {
362  return isset($this->_data['orientation']) ? $this->_data['orientation'] : 'ltr';
363  }
364 
368  public function getPluralRules()
369  {
370  return isset($this->_data['pluralRules']) ? $this->_data['pluralRules'] : array();
371  }
372 
381  public function getLocaleDisplayName($id = null, $category = 'languages')
382  {
383  $id = $this->getCanonicalID($id);
384  if (isset($this->_data[$category][$id]))
385  {
386  return $this->_data[$category][$id];
387  }
388  elseif (($category == 'languages') && ($id = $this->getLanguageID($id)) && (isset($this->_data[$category][$id])))
389  {
390  return $this->_data[$category][$id];
391  }
392  elseif (($category == 'scripts') && ($id = $this->getScriptID($id)) && (isset($this->_data[$category][$id])))
393  {
394  return $this->_data[$category][$id];
395  }
396  elseif (($category == 'territories') && ($id = $this->getTerritoryID($id)) && (isset($this->_data[$category][$id])))
397  {
398  return $this->_data[$category][$id];
399  }
400  else
401  {
402  return null;
403  }
404  }
405  }
406 ?>
getMonthName($month, $width= 'wide', $standAlone=false)
getEraName($era, $width= 'wide')
getCurrencySymbol($currency)
getDateFormat($width= 'medium')
getTimeFormat($width= 'medium')
getMonthNames($width= 'wide', $standAlone=false)
static getInstance($id)
Definition: ZurmoLocale.php:63
getDateFormatForInput($width= 'medium')
getWeekDayName($day, $width= 'wide', $standAlone=false)
static getLocaleIDs()
Definition: ZurmoLocale.php:79
static getSelectableLocaleIds()
getNumberSymbol($name)
getLocaleDisplayName($id=null, $category= 'languages')
__construct($id)
getWeekDayNames($width= 'wide', $standAlone=false)
Generated on Wed Sep 30 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.