Sha256: 087330321eb1ec7bbb1b0507b1cd23900751ac3342c09f5385bd857767a7e322
Contents?: true
Size: 1.55 KB
Versions: 15
Compression:
Stored size: 1.55 KB
Contents
# encoding: utf-8 # # This file is part of the lazier 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 Lazier # A utility class to localize messages class Localizer include Lazier::I18n # Initialize a new localizer. # # @param root [Symbol] The root level of the translation. # @param path [String] The path where the translations are stored. # @param locale [String|Symbol] The locale to use for localization. def initialize(root = nil, path = nil, locale = nil) i18n_setup(root || :lazier, path || ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")) self.i18n = locale end # Localize a message. # # @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(message, *args) Lazier::Localizer.new.i18n.send(message, *args) 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) Lazier::Localizer.new(nil, nil, locale).i18n.send(message, *args) end end end
Version data entries
15 entries across 15 versions & 1 rubygems