Sha256: 926ef1ebcfffb6bf01fcc8f644131daf1989caaca2a1e9e9693076fa7abfcc8d

Contents?: true

Size: 604 Bytes

Versions: 153

Compression:

Stored size: 604 Bytes

Contents

module RubyApp

  module Mixins

    module TranslateMixin
      require 'ruby_app'

      def translate

        name = self.is_a?(Class) ? self.to_s : self.class.to_s
        name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
        name.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
        name.tr!("-", "_")
        name.downcase!

        names = name.split('::')

        value = RubyApp::Language.t
        names.each do |name|
          value = value[name]
        end

        return value

      end

      def localize(*parameters)
        return RubyApp::Language.l(*parameters)
      end

    end

  end

end

Version data entries

153 entries across 153 versions & 1 rubygems

Version Path
RubyApp-0.5.39 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.38 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.37 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.36 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.35 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.34 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.33 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.32 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.31 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.30 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.29 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.28 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.23 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.18 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.17 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.16 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.15 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.14 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.13 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.12 lib/ruby_app/mixins/translate_mixin.rb