Sha256: 324b66186c311aee6bc1ca61f317b3e3bca71e5b0e0e0f177e07872397116a18

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

# Class in my gem
require 'express_translate/express_translate_model'
require 'express_translate/database_management'
require 'express_translate/account_management'
require 'express_translate/package_management'
require 'express_translate/languages_management'
require 'express_translate/language_detail_management'

# Seeds
require 'seeds/packages_seed'
require 'seeds/languages_seed'
require 'seeds/accounts_seed'

# Lib
require 'redis'

# Main module for my gem
module ExpressTranslate
  
  class << self; attr_accessor :package, :language, :url end
  
  @package = ""
  @language = ""
  @url = ""
  
  # Change language locals for I18N
  # lang: is a code of language want to change for backend
  def language(lang)
    I18n.locale = "#{YAML.load_file(Rails.root.to_s + '/config/express_translate.yml')['package']['id']}#{lang}"
  end
  
  def self.root
    File.expand_path '../..', __FILE__
  end
  
  def self.config
    YAML.load_file(Rails.root.to_s + "/config/express_translate.yml")
  end
  
  def self.seeds
    if Package.all.count == 0
      Package.seed
      Language.seed
    end
  end
  
  def self.reset
    Database.clear
  end
  
  def self.clear
    Package.destroy
    Language.destroy
    LanguageDetail.destroy
  end
  
  # def initialize
  #
  # end
      
  # Setup My gem
  def self.setup
    yield self        
  end
  
  class Engine < Rails::Engine
    TRANSLATION_STORE = Redis.new
    I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(TRANSLATION_STORE), I18n.backend)
    I18n.locale = "been"
    
    config.generators do |g|
      g.test_framework :rspec, fixture: true
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
      g.view_specs false
      g.helper_specs false
      g.stylesheets = false
      g.javascripts = false
      g.helper = false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
express_translate-1.0.3 lib/express_translate.rb
express_translate-1.0.2 lib/express_translate.rb
express_translate-1.0.1 lib/express_translate.rb