Module: SexySlug
- Defined in:
- lib/sexy_slug.rb,
lib/sexy_slug/i18n.rb,
lib/sexy_slug/version.rb
Defined Under Namespace
Modules: AbbreviationDot, ActiveSupportComposableChar, ActiveSupportParameterize, Apostrophe, DateTimeDelimiter, Logogram, MoneyAmount, NumberDelimiter, NumberSign, ShortNumber, SignificantDot, Underscore, UnreadableChar, UsuallyTransliterableChar
Constant Summary
collapse
- PROCESSORS =
[
ActiveSupportComposableChar,
UnreadableChar,
Apostrophe,
NumberDelimiter,
DateTimeDelimiter,
MoneyAmount,
AbbreviationDot,
Logogram,
NumberSign,
ShortNumber,
SignificantDot,
Underscore,
UsuallyTransliterableChar,
ActiveSupportParameterize,
]
- TRANSLATIONS =
YAML.load(File.read(__FILE__).split('__END__').last)
- LOCALES =
TRANSLATIONS.keys.map(&:to_sym)
- VERSION =
'1.0.2'
Class Method Summary
collapse
Class Method Details
.from(string) ⇒ Object
7
8
9
|
# File 'lib/sexy_slug.rb', line 7
def self.from(string)
PROCESSORS.inject(string.to_s) { |str, processor| processor.call(str) }
end
|
.locale ⇒ Object
11
12
13
|
# File 'lib/sexy_slug/i18n.rb', line 11
def self.locale
defined?(I18n) && LOCALES.include?(I18n.locale) ? I18n.locale : :en
end
|
.t(path) ⇒ Object
7
8
9
|
# File 'lib/sexy_slug/i18n.rb', line 7
def self.t(path)
path.split('.').inject(TRANSLATIONS[locale.to_s]) { |obj, key| obj[key] }
end
|