Module: I18n
- Defined in:
- lib/routing.rb,
lib/ext/i18n.rb,
lib/i18n_backend_database/database.rb
Defined Under Namespace
Modules: Backend, BackendDatabase
Constant Summary
collapse
- APP_DIRECTORY =
'app/views'
Class Method Summary
collapse
Class Method Details
.asset_translations(dir = APP_DIRECTORY) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ext/i18n.rb', line 39
def asset_translations(dir=APP_DIRECTORY)
assets = []
Dir.glob("#{dir}/*").each do |item|
if File.directory?(item)
assets += asset_translations(item)
else
File.readlines(item).each do |l|
assets += l.scan(/I18n.ta\(["'](.*?)["']\)/).flatten
end
end
end
assets.uniq
end
|
.locale_segment ⇒ Object
Also known as:
ls
6
7
8
|
# File 'lib/ext/i18n.rb', line 6
def locale_segment
I18n.locale.to_s == I18n.default_locale.to_s ? "" : "/#{I18n.locale}"
end
|
.localize_text(text, options = {}) ⇒ Object
Also known as:
lt
11
12
13
14
|
# File 'lib/ext/i18n.rb', line 11
def localize_text(text, options = {})
locale = options[:locale] || I18n.locale
backend.localize_text(locale, text)
end
|
.tag_localized_text(text) ⇒ Object
Also known as:
tlt
17
18
19
|
# File 'lib/ext/i18n.rb', line 17
def tag_localized_text(text)
backend.localize_text_tag + text + backend.localize_text_tag
end
|
.translate_asset(asset, options = {}) ⇒ Object
Also known as:
ta
22
23
24
25
26
27
28
29
|
# File 'lib/ext/i18n.rb', line 22
def translate_asset(asset, options={})
locale = options.delete(:locale) || I18n.locale
if locale_asset = locale_asset(asset, locale)
locale_asset
else
asset
end
end
|
.untranslated_assets(locale) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/ext/i18n.rb', line 32
def untranslated_assets(locale)
return [] if locale.to_s == I18n.default_locale.to_s assets = asset_translations
assets.reject! {|asset| locale_asset_exists?(locale, asset) }
assets
end
|