diff --git a/.gitignore b/.gitignore index 37a28c0f..e281cf22 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ rdoc *.sqlite3 *.gem .ruby-* +.idea/ \ No newline at end of file diff --git a/lib/stringex/localization.rb b/lib/stringex/localization.rb index 1629d2ed..139a2d2d 100644 --- a/lib/stringex/localization.rb +++ b/lib/stringex/localization.rb @@ -11,6 +11,9 @@ module Localization include DefaultConversions class << self + + DOT = ".".freeze + def backend @backend ||= i18n_present? ? Backend::I18n : Backend::Internal end @@ -36,7 +39,7 @@ def store_translations(locale, scope, data) end def translate(scope, key, options = {}) - return if key == "." # I18n doesn't support dots as translation keys so we don't either + return if key == DOT # I18n doesn't support dots as translation keys so we don't either locale = options[:locale] || self.locale diff --git a/lib/stringex/localization/default_conversions.rb b/lib/stringex/localization/default_conversions.rb index a60fb8f9..feb0702c 100644 --- a/lib/stringex/localization/default_conversions.rb +++ b/lib/stringex/localization/default_conversions.rb @@ -78,9 +78,11 @@ module DefaultConversions } class << self - %w{characters currencies html_entities transliterations vulgar_fractions}.each do |conversion_type| - define_method conversion_type do - const_get conversion_type.upcase + # %w{characters currencies html_entities transliterations vulgar_fractions} + + [['characters'.freeze, 'CHARACTERS'.freeze], ['currencies'.freeze, 'CURRENCIES'.freeze], ['html_entities'.freeze, 'HTML_ENTITIES'.freeze], ['transliterations'.freeze, 'TRANSLITERATIONS'.freeze], ['vulgar_fractions'.freeze, 'VULGAR_FRACTIONS'.freeze]].each do |conversion_type| + define_method conversion_type[0] do + const_get conversion_type[1] end end end