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.86 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.85 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.77 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.76 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.75 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.74 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.73 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.72 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.71 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.70 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.69 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.68 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.67 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.66 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.65 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.64 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.63 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.62 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.61 lib/ruby_app/mixins/translate_mixin.rb
RubyApp-0.5.60 lib/ruby_app/mixins/translate_mixin.rb