Sha256: 13b26c7e85eb8a8b29e5af655259041ad5274e9060de935172c0383befdfbdc4

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
#
# This file is part of the bovem gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

module Bovem
  # This class is used to localize strings inside classes methods.
  class Localizer < ::Lazier::Localizer
    # Initialize a new localizer.
    #
    # @param locale [String|Symbol] The locale to use for localization.
    def initialize(locale)
      super("bovem.application", ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/"), locale)
    end

    # Localize a message in a specified locale.
    #
    # @param locale [String|Symbol] The locale to use for localization.
    # @param message [String|Symbol] The message to localize.
    # @param args [Array] Optional arguments to localize the message.
    # @return [String|R18n::Untranslated] The localized message.
    def self.localize_on_locale(locale, message, *args)
      new(locale).i18n.send(message, *args)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bovem-3.0.1 lib/bovem/localizer.rb
bovem-3.0.0 lib/bovem/localizer.rb