README.md in world-flags-0.5.1 vs README.md in world-flags-0.6.0
- old
+ new
@@ -78,18 +78,26 @@
Alternatively
```haml
= flag_list 32 do
- = flag(:ar)
- = flag(:gb, :selected => true)
+ = flag(:ar, 'Argentina')
+ = flag(:gb, 'England', :selected => true)
```
+Or using the locale mappings for the label...
+
+```haml
+= flag_list 32 do
+ = flag(:ar)
+ = flag(:gb, :selected => true)
+```
+
Or using the #flag_code helper
```haml
- = flag(:ar) + flag(:gb, :selected => flag_code(I18n.locale)
+ = flag(:ar, 'Argentina') + flag(:gb, 'England', :selected => flag_code(I18n.locale)
```
You can also include the :with_semi => true option in order to have flags not selected displayed with the 'semi' class (semi-bright image)
For use with tooltips or similar js plguins, it can be useful to set the <li> title attribute:
@@ -108,21 +116,39 @@
Note: The ` is needed in order for the background (flag icon) to have something to be displayed against.
The :title and :content can also be set to a string which is then displayed
```haml
-= flag :ar, :title => 'Argentina country', :content => 'Argh!'
+= flag :ar, 'Argentina', :title => 'Argentina country', :content => 'Argh!'
```
+or using the locale mapping...
+
+```haml
+= flag :ar, :title => 'Argentina country'
+```
+
To get content rendered for the <li>
```haml
= flags :ar, :br, :gb, :content => true
```
Note: There is also a #flag_selected? helper, which is (and/or can be) used to determine if the flag to be drawn should have the "selected" class set)
+## Customizing output
+
+You can customize the output by the flag view helper methods:
+
+```ruby
+WorldFlags.flag_list_tag = :div
+WorldFlags.flag_tag = :span
+WorldFlags.flag_text = ''
+```
+
+To do more customization, look at the `world_flags/helper/view/util.rb` file.
+
## Using localization
You can specify whether to look up labels for the flags for either language or country and for which locale to look up the labels (see Configuring localization)
Use danish (da) country labels
@@ -130,14 +156,15 @@
```haml
= flag_list 32 do
= flags :ar, :br, :gb, :country => :da
```
-Use language labels for current locale
+Use language labels for current locale.
+Note: Also use border class (see CSS below)
```haml
-= flag_list 32 do
+= flag_list 32, :class => 'border' do
= flags :ar, :br, :gb, :language => I18n.locale
```
In the /config folder of this gem/engine there is a json file with all the english _ISO-3166-2_ code translations ready for use. You can make similar locale files for other locales/languages. You can use either of the following:
@@ -192,12 +219,57 @@
```ruby
when :ip
country_code_from_ip browser_ip
```
+## CSS
+
+The `basic.css` file in the `vendor/assets/stylesheets/flags` folder of this repo defines the basic styling of flags. Override these styles to fit your needs.
+
+```ruby
+.flags {
+ list-style-type: none;
+ padding: 0;
+ margin-left: 0;
+}
+
+.flags .l {
+ float: left;
+}
+
+.border .flag {
+ border: 1px solid;
+}
+
+.border .flag.selected {
+ border: 1px solid black;
+}
+
+.f16.flag {
+ line-height: 16px;
+}
+
+.f24.flag {
+ line-height: 24px;
+}
+
+.f32.flag {
+ line-height: 32px;
+}
+
+.f48.flag {
+ line-height: 48px;
+}
+
+.f64.flag {
+ line-height: 64px;
+}
+```
+
## TODO for version 1.0
Suggestions welcome ;)
+
## Enjoy
Copyright (2012) Kristian Mandrup