flag_icon 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7023152e10be1695e958cb558bb33b15e27c27b51d8c90cf14813220aa896e9
4
- data.tar.gz: 06a8bcc0ba25beece903ce1f55d4e5b3d9932d112c4f7336e347eeb13ea2a9ba
3
+ metadata.gz: 2eb44a2a8ed7fb1441698dcea487554797d9a325e94dc85fd56b7652c01d23c6
4
+ data.tar.gz: 95f2d1a9f896e7aa0678dd41bbff73f7cb2f26a2eb747fa9b82b15c40bf2c30e
5
5
  SHA512:
6
- metadata.gz: 83b17fe3252d8d013c08cbb5a2dd1a5b19c4eaf9090be9b4f81c15764a0e13022d31bea74eed1e36a5e9b6725c51d9cd845aa56b4d6f4fd0fa0cebd82584bb9c
7
- data.tar.gz: 51f4badc79a89319e01924246411909df19e9f45b0dfd40e74efb560f6b3afd777899682b9d124f4b08910ca372969203029dafd590663b5133ac77a4601b7d9
6
+ metadata.gz: 8acf0dc35b8fe1fe8afdec533f17062b7dc283431d6b0a96a711d999f2c72f9c81a967c318f7df7a1f8e84567adbec0b4cb36bc4b4d9ac33a5915c91147656b4
7
+ data.tar.gz: 7d949f724295bffd37af1347e7b7ef42a8d705d4fbf6ab199caa420bd2cebd13684e5ff6662c3016b954f758cae5eb064b765686d6bb29b4b07117d7b730121c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flag_icon (1.4.1)
4
+ flag_icon (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,16 +2,15 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/flag_icon.svg)](https://badge.fury.io/rb/flag_icon)
3
3
 
4
4
  ### Purpose
5
- An attempt to map languages to flags!
5
+ An attempt to map languages to country flags!
6
6
 
7
7
  ### Approach
8
8
  Matching flags to languages can be really tricky and even problematic sometimes because there is no direct association
9
- between languages and countries since the same language is spoken in many countries and many languages are spoken in a single.
10
- So a effort was made to identify the official language of each country and then assign the flag to the language not the country.
9
+ between languages and countries since the same language is spoken in many countries and many languages are spoken in a single country.
11
10
 
12
11
  So for a title from Mexico which has spanish as the official language the spanish flag will appear.
13
12
 
14
- Therefore if you notice any flags being mismatched please raise an [issue](https://github.com/alexwebgr/flag_icon/issues)
13
+ If you notice any flags being mismatched please raise an [issue](https://github.com/alexwebgr/flag_icon/issues)
15
14
  or even better open a [pull request](https://github.com/alexwebgr/flag_icon/pulls)
16
15
 
17
16
 
@@ -43,12 +42,12 @@ There is a number of helpers available that will render country names, language
43
42
  language_icon
44
43
  ```
45
44
  ```ruby
46
- # It returns HTML element with country icon
45
+ # It returns HTML element with country icon and title
47
46
  #
48
47
  # @param code -> country iso code
49
- # @example county_icon('gr')
48
+ # @example country_icon('gr')
50
49
  # @return String
51
- county_icon
50
+ country_icon
52
51
  ```
53
52
  ```ruby
54
53
  # It returns the language name
@@ -62,7 +61,7 @@ language_name
62
61
  # It returns the country name
63
62
  #
64
63
  # @param code -> country iso code
65
- # @example language_name('gr') # => Greece
64
+ # @example country_name('gr') # => Greece
66
65
  # @return String
67
66
  country_name
68
67
  ```
@@ -70,18 +69,25 @@ country_name
70
69
  # It returns the country iso code
71
70
  #
72
71
  # @param code -> language locale
73
- # @example language_name('el') # => gr
72
+ # @example language_flag('el') # => gr
74
73
  # @return String
75
74
  language_flag
76
75
  ```
77
76
  ```ruby
78
- # It returns the country iso code
77
+ # It returns an array that can be used in the select tag
78
+ #
79
+ # @example select_language
80
+ # @return Array
81
+ select_language
82
+ ```
83
+ ```ruby
84
+ # It returns an hash of arrays that can be used in the select tag
79
85
  #
80
86
  # @param popular -> title of the popular group
81
87
  # @param available -> title of the available group
82
- # @example select_language
88
+ # @example grouped_select_language(popular: 'Popular', available: 'Available')
83
89
  # @return Hash
84
- select_language
90
+ grouped_select_language
85
91
  ```
86
92
  ```ruby
87
93
  # Define in your application_helper to override the popular languages
@@ -11,7 +11,7 @@ module FlagIcon
11
11
  # It returns the country name
12
12
  #
13
13
  # @param code -> country iso code
14
- # @example language_name('gr') # => Greece
14
+ # @example country_name('gr') # => Greece
15
15
  # @return String
16
16
  def country_name(code)
17
17
  FlagIcon::Countries::NAMES[code.to_sym]
@@ -20,42 +20,49 @@ module FlagIcon
20
20
  # It returns the country iso code
21
21
  #
22
22
  # @param code -> language locale
23
- # @example language_name('el') # => gr
23
+ # @example language_flag('el') # => gr
24
24
  # @return String
25
25
  def language_flag(code)
26
26
  FlagIcon::Countries::LANGUAGE_FLAGS[code.to_sym] || 'xx'
27
27
  end
28
28
 
29
- # It returns the country iso code
29
+ # It returns an array that can be used in the select tag
30
+ #
31
+ # @example select_language
32
+ # @return Array
33
+ def select_language
34
+ available_languages.map { |lang| [language_name(lang), lang] }
35
+ end
36
+
37
+ # It returns an hash of arrays that can be used in the select tag
30
38
  #
31
39
  # @param popular -> title of the popular group
32
40
  # @param available -> title of the available group
33
- # @example select_language
41
+ # @example grouped_select_language(popular: 'Popular', available: 'Available')
34
42
  # @return Hash
35
- def select_language(popular = 'Popular', available = 'Available')
43
+ def grouped_select_language(popular: 'Popular', available: 'Available')
36
44
  {
37
45
  popular => popular_languages,
38
46
  available => available_languages.map { |lang| [language_name(lang), lang] }
39
47
  }
40
48
  end
41
49
 
42
-
43
50
  # It returns HTML element with country icon and title
44
51
  #
45
52
  # @param code -> language locale
46
53
  # @example language_icon('el')
47
54
  # @return String
48
- def language_icon(code)
49
- "<span class='flag-icon flag-icon-#{language_flag(code)}' title='Audio language - #{language_name(code)}'></span>"
55
+ def language_icon(code, title: "Audio language - #{language_name(code)}")
56
+ "<span class='flag-icon flag-icon-#{language_flag(code)}' title='#{title}'></span>"
50
57
  end
51
58
 
52
- # It returns HTML element with country icon
59
+ # It returns HTML element with country icon and title
53
60
  #
54
61
  # @param code -> country iso code
55
- # @example county_icon('gr')
62
+ # @example country_icon('gr')
56
63
  # @return String
57
- def county_icon(code)
58
- "<span class='flag-icon flag-icon-#{code}' title='Available in #{country_name(code)}'></span>"
64
+ def country_icon(code, title: "Available in #{country_name(code)}")
65
+ "<span class='flag-icon flag-icon-#{code}' title='#{title}'></span>"
59
66
  end
60
67
 
61
68
  # Define in your application_helper to override the popular languages
@@ -86,8 +93,9 @@ module FlagIcon
86
93
  module_function :country_name
87
94
  module_function :language_flag
88
95
  module_function :select_language
96
+ module_function :grouped_select_language
89
97
  module_function :language_icon
90
- module_function :county_icon
98
+ module_function :country_icon
91
99
  module_function :popular_languages
92
100
  module_function :available_languages
93
101
  end
@@ -1,5 +1,5 @@
1
1
  module FlagIcon
2
2
  module Rails
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flag_icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexwebgr