Sha256: 5879981b35268573924a65822de352ba1265f46b0505c3010d485b0d32bbf87c
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
class GettextSimpleRails::CacheHandler def newest_po_file newest_time = nil newest_path = nil I18n.available_locales.each do |locale| default_path_file = "#{Rails.root}/config/locales_gettext/#{locale}/LC_MESSAGES/default.po" next unless File.exists?(default_path_file) time = File.mtime(default_path_file) newest_time = time if newest_time == nil || time > newest_time newest_path = default_path_file end return newest_path end def static_cache_file_path "#{Rails.root}/config/locales_gettext/static_translation_file.json" end def cache_file_too_old? if !File.exists?(static_cache_file_path) return true elsif File.mtime(static_cache_file_path) < File.mtime(newest_po_file) return true else return false end end def write_static_translation_file require "gettext_simple" gs = GettextSimple.new(:i18n => true) gs.load_dir("#{Rails.root}/config/locales_gettext") gs.register_kernel_methods injector = GettextSimpleRails::I18nInjector.new(:store_in_hash => true) injector.inject_model_translations(gs) injector.inject_translator_translations(gs) File.open(static_cache_file_path, "w") do |fp| fp.write(injector.store_hash.to_json) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gettext_simple_rails-0.0.9 | lib/gettext_simple_rails/cache_handler.rb |