http_accept
HTTP::Accept
Provides parser for dealing with HTTP Accept-Language
headers.
Inspired by Ruby http-accept gem
Installation
-
Add the dependency to your
shard.yml
:dependencies: http_accept: github: BecauseOfProg/http_accept
-
Run
shards install
Usage
require "http_accept"
# wanted_languages = HTTP::Accept::Language.parse("da, en-gb;q=0.8, en;q=0.7")
http_headers : HTTP::Headers
wanted_languages : Array(HTTP::Accept::Language::Value)? = nil
if http_headers["Accept-Language"]?
wanted_languages = HTTP::Accept::Language.parse(http_headers["Accept-Language"])
end
HTTP::Accept::Language.best_locale(["en", "fr"], wanted_languages) # => "en"
HTTP::Accept::Language.best_locale(["fr", "nl"], wanted_languages, "fr") # => "fr"
HTTP::Accept::Language.best_locale(["en", "fr"], nil) # => "en"
TODO: Write usage instructions here
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/BecauseOfProg/http_accept/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Nicolas Martinussen - creator and maintainer
Repository
http_accept
Owner
Statistic
- 2
- 0
- 0
- 0
- 0
- over 3 years ago
- April 24, 2021
License
Links
Synced at
Mon, 25 Nov 2024 13:57:06 GMT
Languages