Open Journal Systems  2.4.3
 All Classes Namespaces Functions Variables Groups Pages
env1/MockAppLocale.inc.php
1 <?php
2 
16 define('LOCALE_REGISTRY_FILE', 'lib/pkp/tests/registry/locales.xml');
17 define('LOCALE_ENCODING', 'utf-8');
18 
19 define('LOCALE_COMPONENT_APPLICATION_COMMON', 0x00000101);
20 define('LOCALE_COMPONENT_OJS_EDITOR', 0x00000103);
21 
22 import('lib.pkp.classes.i18n.PKPLocale');
23 
24 class AppLocale extends PKPLocale {
25  static
26  $primaryLocale = 'en_US',
27  $supportedLocales = array('en_US' => 'English/America'),
28  $translations = array();
29 
30  /*
31  * method required during setup of
32  * the PKP application framework
33  */
34  function initialize() {
35  // do nothing
36  }
37 
38  /*
39  * method required during setup of
40  * the PKP application framework
41  * @return string test locale
42  */
43  function getLocale() {
44  return 'en_US';
45  }
46 
47  /*
48  * method required during setup of
49  * the PKP application framework
50  */
51  function registerLocaleFile($locale, $filename, $addToTop = false) {
52  // do nothing
53  }
54 
59  function requireComponents() {
60  // do nothing
61  }
62 
67  function getLocalePrecedence() {
68  return array('en_US', 'fr_FR');
69  }
70 
78  function translate($key, $params = array(), $locale = null) {
79  if (isset(self::$translations[$key])) {
80  return self::$translations[$key];
81  }
82  return "##$key##";
83  }
84 
90  function setPrimaryLocale($primaryLocale) {
91  self::$primaryLocale = $primaryLocale;
92  }
93 
98  function getPrimaryLocale() {
99  return self::$primaryLocale;
100  }
101 
111  function setSupportedLocales($supportedLocales) {
112  self::$supportedLocales = $supportedLocales;
113  }
114 
119  function getSupportedLocales() {
120  return self::$supportedLocales;
121  }
122 
128  return array('en_US');
129  }
130 
135  static function setTranslations($translations) {
136  self::$translations = $translations;
137  }
138 }
139 ?>
Provides methods for loading locale data and translating strings identified by unique keys...
setSupportedLocales($supportedLocales)
setPrimaryLocale($primaryLocale)
static setTranslations($translations)
Provides methods for loading locale data and translating strings identified by unique keys...
translate($key, $params=array(), $locale=null)