Class: ArcadiaLocalization
- Inherits:
-
Object
- Object
- ArcadiaLocalization
- Includes:
- Configurable
- Defined in:
- lib/a-core.rb
Constant Summary collapse
- KEY_CACHE_VERSION =
'__VERSION__'
- STANDARD_LOCALE =
'en-UK'
- PARAM_SIG =
'$'
Constants included from Configurable
Configurable::ADD_SYMBOL, Configurable::FONT_TYPE_SYMBOL, Configurable::LC_SYMBOL, Configurable::LINK_SYMBOL
Instance Attribute Summary collapse
-
#lc_lang ⇒ Object
readonly
Returns the value of attribute lc_lang.
Instance Method Summary collapse
-
#initialize ⇒ ArcadiaLocalization
constructor
A new instance of ArcadiaLocalization.
- #text(_key, _params = nil) ⇒ Object
Methods included from Configurable
clear_properties_group_cache, #hash2properties_file, #make_locale_value, #make_value, #properties_file2hash, properties_group, #resolve_locale_value, #resolve_properties_link, #resolve_value
Constructor Details
#initialize ⇒ ArcadiaLocalization
Returns a new instance of ArcadiaLocalization.
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 |
# File 'lib/a-core.rb', line 2194 def initialize @standard_locale=Arcadia.conf("locale.standard").nil? ? STANDARD_LOCALE : Arcadia.conf("locale.standard") @locale=Arcadia.conf("locale").nil? ? STANDARD_LOCALE : Arcadia.conf("locale") lc_lang_standard_file="conf/LC/#{Arcadia.conf('locale.standard')}.LANG" lc_lang_locale_file="conf/LC/#{Arcadia.conf('locale')}.LANG" need_cache_update = false if @standard_locale == @locale || !File.exist?(lc_lang_locale_file) @lc_lang = properties_file2hash(lc_lang_standard_file) if File.exist?(lc_lang_standard_file) else lc_lang_cache_file=File.join(Arcadia.local_dir, "#{Arcadia.conf('locale')}.LC_LANG_CACHE") if File.exist?(lc_lang_cache_file) @lc_lang = properties_file2hash(lc_lang_cache_file) if @lc_lang[KEY_CACHE_VERSION] != Arcadia.version # is to update need_cache_update = true end else need_cache_update = true end if need_cache_update @lc_lang = properties_file2hash(lc_lang_standard_file) @lc_lang.each_pair{|key,value| @lc_lang[key] = "#{@locale}:#{value}"} if File.exist?(lc_lang_locale_file) lc_lang_locale = properties_file2hash(lc_lang_locale_file) else lc_lang_locale = {} end lc_lang_locale.each{|k,v| @lc_lang[k]=v} @lc_lang[KEY_CACHE_VERSION]=Arcadia.version hash2properties_file(@lc_lang, lc_lang_cache_file) end end end |
Instance Attribute Details
#lc_lang ⇒ Object (readonly)
Returns the value of attribute lc_lang.
2193 2194 2195 |
# File 'lib/a-core.rb', line 2193 def lc_lang @lc_lang end |
Instance Method Details
#text(_key, _params = nil) ⇒ Object
2228 2229 2230 2231 2232 2233 2234 |
# File 'lib/a-core.rb', line 2228 def text(_key, _params = nil) ret = @lc_lang.nil?||@lc_lang[_key].nil? ? "?" : @lc_lang[_key] if !_params.nil? _params.each_with_index{|param, i| ret = ret.gsub("#{PARAM_SIG}#{i}", param.to_s) } end ret end |