i18n_locales 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d9a8af9dd44698f53c6a3112a54bc94dfb053b2
4
+ data.tar.gz: 5dea8724fd4e872858609274be5ca4a632510b3d
5
+ SHA512:
6
+ metadata.gz: 58da16eeeceefa76bffca49e12ab2b6e7ac93054f92833f3b2f50508e88105450e8d36e7a521ed8fa94f3ecd604e595dbcadaf0a61d94af3b3f2bb312f071536
7
+ data.tar.gz: cbc759db45a719a38f680fa0250d727592409a71094b66ee749c4eb1bf6b2941d3190a208c804e40d0385cde322490264a466ee446e9709dd00ff72a87e6dfd3
@@ -0,0 +1,2 @@
1
+ 5Nl뭇_��O����/�͚v�xd�
2
+ z��=~�<@5���D����X*B��c*f��ʝ� l�2�L҇�D��`&�Lw&��0ƹq(ᨔa��ˬ����^���}�D9�(�����`ޜ�JD尝�s�S��c�j�$��M��2�l>�M�<4P�F���Z����ќ|��keL�����H�:��#6 �Q #�Rp�]w=�0��}�s��*�-�
@@ -0,0 +1 @@
1
+ ��'���j��$.-Q�|�9�����$fY�RsD^3?����ڙK�_�`��2��3�"��Y�n�; �7�n�\��"Ќ��/9���,w�L�t!�������l)w����4sHɜ��Ǥ���r�ׯnZ��,�jP�`o��uN��$ə�Ps��������5�Q5�gCY���2��(��g_y�����3Q��{�sl��N��PrXx�VJ�W3�h����j؅ʻ{�'?������u;�.�#W~&�(
@@ -0,0 +1,73 @@
1
+ require 'yaml'
2
+
3
+ module I18nLocales
4
+ extend self
5
+
6
+ def raw
7
+ @@raw ||= YAML.load_file('data/pairs.yaml')
8
+ end
9
+
10
+ # country XX is %C
11
+ # country xx is %c
12
+ # language XX is %L
13
+ # language xx is %l
14
+ # % is %%
15
+ # default is %c-%L
16
+ class << self
17
+ attr_accessor :format
18
+ end
19
+ self.format = '%c-%L'
20
+
21
+ def all
22
+ where
23
+ end
24
+
25
+ def match_country(country, find_by_country=nil)
26
+ if find_by_country.is_a? Array
27
+ find_by_country.map(&:downcase).include? country.downcase
28
+ elsif find_by_country.is_a? String
29
+ $stderr.puts "find_by_country=#{find_by_country} #{find_by_country.class} == #{country} #{country.class}"
30
+ find_by_country.downcase == country.downcase
31
+ else
32
+ true
33
+ end
34
+ end
35
+
36
+ def match_language(language, find_by_language=nil)
37
+ if find_by_language.is_a? Array
38
+ find_by_language.map(&:upcase).include? language.upcase
39
+ elsif find_by_language.is_a? String
40
+ find_by_language.upcase == language.upcase
41
+ else
42
+ true
43
+ end
44
+ end
45
+
46
+ def where(find_by_language=nil, find_by_country=nil, with_format=nil)
47
+ raw.map { |country, languages|
48
+ next unless match_country(country, find_by_country)
49
+ languages.map { |language|
50
+ next unless match_language(language, find_by_language)
51
+ Pair.new(country, language, with_format)
52
+ }.compact unless languages.nil?
53
+ }.flatten.compact
54
+ end
55
+
56
+ class Pair
57
+ attr_accessor :country, :language, :format
58
+
59
+ def initialize(country, language, format=nil)
60
+ @country = country
61
+ @language = language
62
+ @format = format || I18nLocales.format
63
+ end
64
+
65
+ def to_s
66
+ format.gsub('%C', country.upcase)
67
+ .gsub('%L', language.upcase)
68
+ .gsub('%c', country.downcase)
69
+ .gsub('%l', language.downcase)
70
+ .gsub('%%', '%')
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ module I18nLocales
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n_locales
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Barry Allard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDOjCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxiYXJy
14
+ eS5hbGxhcmQxF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8odDSVDWzUfkZmOQt
30
+ ViIxU1ZphInql7L5g34=
31
+ -----END CERTIFICATE-----
32
+ date: 2014-03-24 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec-core
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ description:
77
+ email: barry.allard@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/i18n_locales.rb
83
+ - lib/i18n_locales/version.rb
84
+ homepage: https://github.com/steakknife/i18n_locales
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: languages X country codes
108
+ test_files: []
109
+ has_rdoc:
Binary file