air18n 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/air18n.rb +0 -1
- data/lib/air18n/class_methods.rb +0 -43
- data/lib/air18n/version.rb +1 -1
- data/make_gem +1 -1
- metadata +2 -2
data/lib/air18n.rb
CHANGED
data/lib/air18n/class_methods.rb
CHANGED
@@ -230,49 +230,6 @@ module Air18n
|
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
# Replaces LOCALE and COUNTRY, if they are present in path, with
|
234
|
-
# I18n.locale and I18n.country. You can explicitly set the locale and
|
235
|
-
# country with options[:locale] and options[:country].
|
236
|
-
#
|
237
|
-
# Use this if the resource you reference lives under public/. For example,
|
238
|
-
# to reference an image file, pass just call e.g.
|
239
|
-
# localized_public_path("/images/buttons/awesome-LOCALE.png").
|
240
|
-
def localized_public_path(path_relative_to_public, options = {})
|
241
|
-
localized_path(path_relative_to_public, options.merge({:absolute_prefix_on_disk => Rails.public_path}))
|
242
|
-
end
|
243
|
-
|
244
|
-
# Replaces LOCALE and COUNTRY, if they are present in path, with
|
245
|
-
# I18n.locale and I18n.country. You can explicitly set the locale and
|
246
|
-
# country with options[:locale] and options[:country].
|
247
|
-
#
|
248
|
-
# If path is not absolute, you must also set
|
249
|
-
# options[:absolute_prefix_on_disk] so that absolute_prefix_on_disk+path is
|
250
|
-
# a valid absolute path (after locale or country interpolations).
|
251
|
-
# If you are referencing something in public/, you should use
|
252
|
-
# localized_public_path.
|
253
|
-
#
|
254
|
-
# If the file does not exist after interpolation, LOCALE will be replaced
|
255
|
-
# with "en" and COUNTRY will be replaced with "us".
|
256
|
-
def localized_path(path, options = {})
|
257
|
-
options[:locale] ||= I18n.locale
|
258
|
-
options[:country] ||= I18n.country
|
259
|
-
localized_path_explicit_locale(path, options)
|
260
|
-
end
|
261
|
-
|
262
|
-
# Same as localized_path but explicitly uses options[:locale] and
|
263
|
-
# options[:country] so that it can be memoized.
|
264
|
-
def localized_path_explicit_locale(path, options = {})
|
265
|
-
replaced = path.gsub('LOCALE', options[:locale].to_s).gsub('COUNTRY', options[:country].to_s)
|
266
|
-
|
267
|
-
# TODO(jason) Use full locale and its fallbacks.
|
268
|
-
absolute_path = options[:absolute_prefix_on_disk] ? File.join(options[:absolute_prefix_on_disk], "images", replaced) : replaced
|
269
|
-
if File.exist?(absolute_path)
|
270
|
-
replaced
|
271
|
-
else
|
272
|
-
path.gsub('COUNTRY', "US").gsub('LOCALE', "en")
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
233
|
# Add :routes_context option, which is used for translation screenshotting.
|
277
234
|
# I18n.fallback_routes_context is set by an ApplicationController
|
278
235
|
# before_filter.
|
data/lib/air18n/version.rb
CHANGED
data/make_gem
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: air18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-06-
|
16
|
+
date: 2012-06-23 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: i18n
|