Module: FatFreeCRM::I18n
- Defined in:
- lib/fat_free_crm/i18n.rb
Instance Method Summary collapse
-
#languages ⇒ Object
Return a hash where the key is locale name, and the value is language name as defined in the locale_fat_free_crm.yml file.
-
#locales ⇒ Object
Scan config/locales directory for Fat Free CRM localization files (i.e. *_fat_free_crm.yml) and return locale part of the file name.
-
#t(*args) ⇒ Object
—————————————————————————-.
Instance Method Details
#languages ⇒ Object
Return a hash where the key is locale name, and the value is language name as defined in the locale_fat_free_crm.yml file.
36 37 38 |
# File 'lib/fat_free_crm/i18n.rb', line 36 def languages @@languages ||= Hash[ locales.map{ |locale| [ locale, t(:language, locale: locale) ] } ] end |
#locales ⇒ Object
Scan config/locales directory for Fat Free CRM localization files (i.e. *_fat_free_crm.yml) and return locale part of the file name. We can’t use ::I18n.available_locales because rails provides it’s own translations too and we only want the locales that Fat Free CRM supports.
29 30 31 |
# File 'lib/fat_free_crm/i18n.rb', line 29 def locales @@locales ||= ::I18n.load_path.grep(/_fat_free_crm\.yml$/).map{ |path| Pathname.new(path).basename.to_s.match(/(.*)_fat_free_crm\.yml/)[1] }.uniq end |
#t(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fat_free_crm/i18n.rb', line 12 def t(*args) if args.size == 1 super(args.first, default: args.first.to_s) elsif args.second.is_a?(Hash) super(*args) elsif args.second.is_a?(Fixnum) super(args.first, count: args.second) else super(args.first, value: args.second) end end |