lola 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -1
- data/VERSION +1 -1
- data/lib/lola.rb +11 -2
- data/lola.gemspec +1 -1
- data/test/test_lola.rb +2 -4
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/lola.rb
CHANGED
@@ -14,11 +14,12 @@ module Lola
|
|
14
14
|
|
15
15
|
# Raised when attemting to switch to a locale which does not exist
|
16
16
|
class UnavailableLocale < RuntimeError; end
|
17
|
-
|
17
|
+
|
18
18
|
# Returns a list of all languages
|
19
19
|
def self.languages(options={})
|
20
20
|
# Use specified locale or fall back to default locale
|
21
|
-
locale =
|
21
|
+
locale = options.delete(:locale) || @default_locale
|
22
|
+
locale = available_locales.include?(locale) ? locale.to_s : @default_locale.to_s
|
22
23
|
|
23
24
|
# Load the country list for the specified locale
|
24
25
|
@languages ||= {}
|
@@ -65,6 +66,14 @@ module Lola
|
|
65
66
|
end
|
66
67
|
|
67
68
|
protected
|
69
|
+
def self.available_locales
|
70
|
+
locales = Array.new
|
71
|
+
Dir.glob("#{@data_path}/*.yml") do |filename|
|
72
|
+
locales << File.basename(filename, '.yml').to_sym
|
73
|
+
end
|
74
|
+
locales
|
75
|
+
end
|
76
|
+
|
68
77
|
def self.search_collection(collection, value, index_to_match, index_to_retrieve)
|
69
78
|
return nil if collection.nil? || value.nil? || value.empty?
|
70
79
|
collection.each do |m|
|
data/lola.gemspec
CHANGED
data/test/test_lola.rb
CHANGED
@@ -38,7 +38,7 @@ class TestLola < Test::Unit::TestCase
|
|
38
38
|
Lola.default_locale = :es
|
39
39
|
assert_equal 'Griego', Lola.language_name('EL')
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def test_language_code
|
43
43
|
assert_equal 'ES', Lola.language_code('Spanish')
|
44
44
|
assert_equal 'ES', Lola.language_code('spanish')
|
@@ -84,9 +84,7 @@ class TestLola < Test::Unit::TestCase
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_unsupported_locale
|
87
|
-
|
88
|
-
Lola.languages(:locale => :latin)
|
89
|
-
end
|
87
|
+
assert_equal 'English', Lola.language_name('EN', :locale => :latin)
|
90
88
|
end
|
91
89
|
|
92
90
|
def test_special_characters_dont_rails_an_exception
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lola
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash: -
|
117
|
+
hash: -205451062462248237
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|