Sha256: af4c187461b58a62fcce27a4352c59a1c311d356cef4bc8881e7e693e9b1782c

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding: utf-8 -*-

module Typus
  module I18n

    class << self

      ##
      # Instead of having to translate strings and defining a default value:
      #
      #     Typus::I18n.t("Hello World!", :default => 'Hello World!')
      #
      # We define this method to define the value only once:
      #
      #     Typus::I18n.t("Hello World!")
      #
      # Note that interpolation still works:
      #
      #     Typus::I18n.t("Hello %{world}!", :world => @world)
      #
      def t(msg, *args)
        options = args.extract_options!
        options[:default] = msg
        ::I18n.t(msg, options)
      end

      def default_locale
        :en
      end

      def available_locales
        { "Brazilian Portuguese" => "pt-BR",
          "Català" => "ca",
          "German" => "de",
          "Greek"  => "el",
          "Italiano" => "it",
          "English" => "en",
          "Español" => "es",
          "Français" => "fr",
          "Magyar" => "hu",
          "Portuguese" => "pt-PT",
          "Russian" => "ru",
          "中文" => "zh-CN" }
      end

    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
typus-3.1.2 lib/typus/i18n.rb
typus-3.1.1 lib/typus/i18n.rb
typus-3.1.0 lib/typus/i18n.rb
typus-3.1.0.rc19 lib/typus/i18n.rb
typus-3.1.0.rc18 lib/typus/i18n.rb
typus-3.1.0.rc17 lib/typus/i18n.rb
typus-3.1.0.rc16 lib/typus/i18n.rb
typus-3.1.0.rc15 lib/typus/i18n.rb
typus-3.1.0.rc14 lib/typus/i18n.rb
typus-3.1.0.rc13 lib/typus/i18n.rb
typus-3.1.0.rc12 lib/typus/i18n.rb