{"id":15603304,"url":"https://github.com/alexwebgr/flag_icon","last_synced_at":"2026-05-29T21:31:36.558Z","repository":{"id":45093151,"uuid":"445847677","full_name":"alexwebgr/flag_icon","owner":"alexwebgr","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-09T16:02:27.000Z","size":776,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T18:05:55.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexwebgr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-08T14:53:34.000Z","updated_at":"2022-01-09T16:02:30.000Z","dependencies_parsed_at":"2022-09-22T17:02:28.030Z","dependency_job_id":null,"html_url":"https://github.com/alexwebgr/flag_icon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fflag_icon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fflag_icon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fflag_icon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fflag_icon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexwebgr","download_url":"https://codeload.github.com/alexwebgr/flag_icon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241802548,"owners_count":20022671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T03:02:31.471Z","updated_at":"2026-05-29T21:31:36.552Z","avatar_url":"https://github.com/alexwebgr.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FlagIcon\n[![Gem Version](https://badge.fury.io/rb/flag_icon.svg)](https://badge.fury.io/rb/flag_icon)\n\n### Purpose\nAn attempt to map languages to country flags!\n\n### Approach\nMatching flags to languages can be really tricky and even problematic sometimes because there is no direct association\nbetween languages and countries since the same language is spoken in many countries and many languages are spoken in a single country.\n\nSo for a title from Mexico which has spanish as the official language the spanish flag will appear.\n\nIf you notice any flags being mismatched please raise an [issue](https://github.com/alexwebgr/flag_icon/issues)\nor even better open a [pull request](https://github.com/alexwebgr/flag_icon/pulls)\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'flag_icon'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install flag_icon\n\n## Usage\nThere is a number of helpers available that will render country names, language names and flags given a country code or locale.\n\n```ruby\n# It returns HTML element with country icon and title\n#\n# @param code -\u003e language locale\n# @example language_icon('el')\n# @return String\nlanguage_icon\n```\n```ruby\n# It returns HTML element with country icon and title\n#\n# @param code -\u003e country iso code\n# @example country_icon('gr')\n# @return String\ncountry_icon\n```\n```ruby\n# It returns the language name\n#\n# @param code -\u003e language locale\n# @example language_name('el') # =\u003e Greek\n# @return String\nlanguage_name\n```\n```ruby\n# It returns the country name\n#\n# @param code -\u003e country iso code\n# @example country_name('gr') # =\u003e Greece\n# @return String\ncountry_name\n```\n```ruby\n# It returns the country iso code\n#\n# @param code -\u003e language locale\n# @example language_flag('el') # =\u003e gr\n# @return String\nlanguage_flag\n```\n```ruby\n# It returns an array that can be used in the select tag\n#\n# @example select_language\n# @return Array\nselect_language\n```\n```ruby\n  # It returns an hash of arrays that can be used in the select tag\n#\n# @param popular -\u003e title of the popular group\n# @param available -\u003e title of the available group\n# @example grouped_select_language(popular: 'Popular', available: 'Available')\n# @return Hash\ngrouped_select_language\n```\n```ruby\n# Define in your application_helper to override the popular languages\n# Default: [['English', :en], ['Spanish', :es]]\n#\n# @example\n#   def popular_languages\n#     [['English', :en], ['Spanish', :es]]\n#   end\n# @return Array\npopular_languages\n```\n```ruby\n# Define in your application_helper to override the available languages\n# @example [['English', :en], ['Spanish', :es]] #default\n# @example\n#   def available_languages\n#     Language.all.order(:language_locale).pluck(:language_locale)\n#   end\n# @return Array\navailable_languages\n\n```\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alexwebgr/flag_icon/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the FlagIcon project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/alexwebgr/flag_icon/blob/master/CODE_OF_CONDUCT.md).\n\n## Credits\n* Flag icons and css from [flag-icons](https://github.com/lipis/flag-icons)\n* Country names [xqisocodes.html](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html)\n* Language to country mapping [country_locale_map.json](https://github.com/riboseinc/country_to_locales_mapping/blob/master/data/country_locale_map.json)\n* Language to country mapping [language-identifiers.html](http://www.i18nguy.com/unicode/language-identifiers.html)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexwebgr%2Fflag_icon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexwebgr%2Fflag_icon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexwebgr%2Fflag_icon/lists"}