Module: IceCube::NullI18n
- Defined in:
- lib/ice_cube/null_i18n.rb
Class Method Summary collapse
Class Method Details
.config ⇒ Object
30 31 32 |
# File 'lib/ice_cube/null_i18n.rb', line 30 def self.config @config ||= YAML.load_file(File.join(IceCube::I18n::LOCALES_PATH, "en.yml"))["en"] end |
.l(date_or_time, options = {}) ⇒ Object
25 26 27 28 |
# File 'lib/ice_cube/null_i18n.rb', line 25 def self.l(date_or_time, = {}) return date_or_time.strftime([:format]) if [:format] date_or_time.strftime(t("ice_cube.date.formats.default")) end |
.t(key, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ice_cube/null_i18n.rb', line 5 def self.t(key, = {}) base = key.to_s.split(".").reduce(config) { |hash, current_key| hash[current_key] } base = base[([:count] == 1) ? "one" : "other"] if [:count] case base when Hash base.each_with_object({}) do |(k, v), hash| hash[k.is_a?(String) ? k.to_sym : k] = v end when Array base.each_with_index.each_with_object({}) do |(v, k), hash| hash[k] = v end else return base unless base.include?("%{") base % end end |