1 | <?php |
||
36 | trait CommonLibLocale |
||
37 | { |
||
38 | |||
39 | protected $commonLibFlags = null; |
||
40 | protected $tCmnLb = null; |
||
41 | protected $tCmnRequest = null; |
||
42 | protected $tCmnSession = null; |
||
43 | protected $tCmnSuperGlobals = null; |
||
44 | |||
45 | private function getCommonLocaleFolder() |
||
57 | |||
58 | /** |
||
59 | * Stores given language or default one into global session variable |
||
60 | * (In order to avoid potential language injections from other applications session will revert |
||
61 | * to the default language if application one is not among the one are not supported here) |
||
62 | * |
||
63 | * @return NOTHING |
||
64 | */ |
||
65 | private function handleLanguageIntoSession() |
||
78 | |||
79 | /** |
||
80 | * Takes care of instatiation of localization libraries |
||
81 | * used within current module for multi-languages support |
||
82 | * |
||
83 | * @return NOTHING |
||
84 | */ |
||
85 | private function handleLocalizationCommon() |
||
86 | { |
||
87 | $this->handleLanguageIntoSession(); |
||
88 | $localizationFile = $this->getCommonLocaleFolder() . '/locale/' |
||
89 | . $this->tCmnSession->get('lang') . '/LC_MESSAGES/' |
||
90 | . $this->commonLibFlags['localization_domain'] |
||
91 | . '.mo'; |
||
92 | $extrClass = new \Gettext\Extractors\Mo(); |
||
93 | $translations = $extrClass->fromFile($localizationFile); |
||
94 | $this->tCmnLb = new \Gettext\Translator(); |
||
95 | $this->tCmnLb->loadTranslations($translations); |
||
96 | } |
||
97 | |||
98 | protected function initializeSprGlbAndSession() |
||
110 | |||
111 | /** |
||
112 | * Central function to deal with multi-language messages |
||
113 | * |
||
114 | * @param string $localizedStringCode |
||
115 | * @return string |
||
116 | */ |
||
117 | protected function lclMsgCmn($localizedStringCode) |
||
118 | { |
||
119 | if (is_null($this->tCmnLb)) { |
||
120 | $this->settingsCommonLib(); |
||
121 | $this->handleLocalizationCommon(); |
||
122 | } |
||
123 | return $this->tCmnLb->gettext($localizedStringCode); |
||
124 | } |
||
125 | |||
126 | protected function lclMsgCmnNumber($singularString, $pluralString, $numberToEvaluate) |
||
134 | |||
135 | /** |
||
136 | * Returns proper result from a mathematical division in order to avoid |
||
137 | * Zero division erorr or Infinite results |
||
138 | * |
||
139 | * @param float $fAbove |
||
140 | * @param float $fBelow |
||
141 | * @param mixed $mArguments |
||
142 | * @return decimal |
||
143 | */ |
||
144 | protected function setDividedResult($fAbove, $fBelow, $mArguments = 0) |
||
158 | |||
159 | protected function setNumberFormat($content, $features = null) |
||
167 | |||
168 | private function setNumberFormatFeatures($features) |
||
187 | |||
188 | /** |
||
189 | * Settings |
||
190 | * |
||
191 | * @return NOTHING |
||
192 | */ |
||
193 | private function settingsCommonLib() |
||
205 | } |
||
206 |