{"id":15491621,"url":"https://github.com/remi/plug_locale_root_redirect","last_synced_at":"2025-12-11T23:31:39.471Z","repository":{"id":57534741,"uuid":"80922823","full_name":"remi/plug_locale_root_redirect","owner":"remi","description":"PlugLocaleRootRedirect uses PlugBest to map '/' route to a path based on the Accept-Language HTTP header.","archived":false,"fork":false,"pushed_at":"2019-03-15T14:15:30.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T10:06:08.052Z","etag":null,"topics":["elixir","http","localization","plug"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/plug_locale_root_redirect","language":"Elixir","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/remi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-04T13:59:08.000Z","updated_at":"2019-03-15T14:15:32.000Z","dependencies_parsed_at":"2022-09-26T18:21:42.524Z","dependency_job_id":null,"html_url":"https://github.com/remi/plug_locale_root_redirect","commit_stats":null,"previous_names":["remiprev/plug_locale_root_redirect"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/remi/plug_locale_root_redirect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_locale_root_redirect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_locale_root_redirect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_locale_root_redirect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_locale_root_redirect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remi","download_url":"https://codeload.github.com/remi/plug_locale_root_redirect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_locale_root_redirect/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263996083,"owners_count":23541399,"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":["elixir","http","localization","plug"],"created_at":"2024-10-02T07:54:38.693Z","updated_at":"2025-12-11T23:31:34.415Z","avatar_url":"https://github.com/remi.png","language":"Elixir","readme":"PlugLocaleRootRedirect\n=================\n\n[![Travis](https://img.shields.io/travis/remiprev/plug_locale_root_redirect.svg?style=flat-square)](https://travis-ci.org/remiprev/plug_locale_root_redirect)\n[![Hex.pm](https://img.shields.io/hexpm/v/plug_locale_root_redirect.svg?style=flat-square)](https://hex.pm/packages/plug_locale_root_redirect)\n\n`PlugLocaleRootRedirect` ensures that all requests to the root path (`/`) are\nredirected to the best locale path (eg. `/fr`, `/en`, etc.), from a list of supported\nlocales.\n\nInstallation\n------------\n\nAdd `plug_locale_root_redirect` to the `deps` function in your project's `mix.exs` file:\n\n```elixir\ndefp deps do\n  [\n    …,\n    {:plug_locale_root_redirect, \"~\u003e 0.3\"}\n  ]\nend\n```\n\nThen run `mix do deps.get, deps.compile` inside your project's directory.\n\nUsage\n-----\n\n`PlugLocaleRootRedirect` can be used just as any other plugs. Add\n`PlugLocaleRootRedirect` before all of the other plugs you want to happen after\nsuccessful redirection to your locale path.\n\n```elixir\ndefmodule Endpoint do\n  plug PlugLocaleRootRedirect, locales: ~w(en fr)\nend\n```\n\nThe result:\n\n```bash\n$ curl -sI \"http://localhost:4000\" -H \"Accept-Language: fr;q=1, en;q=0.8\" | grep \"302\\|Location\"\nHTTP/1.1 302 Found\nLocation: /fr\n\n$ curl -sI \"http://localhost:4000\" -H \"Accept-Language: fr;q=0.4, en;q=0.8\" | grep \"302\\|Location\"\nHTTP/1.1 302 Found\nLocation: /en\n\n$ curl -sI \"http://localhost:4000\" -H \"Accept-Language: es;q=1, ru;q=0.5\" | grep \"302\\|Location\"\nHTTP/1.1 302 Found\nLocation: /en\n\n$ curl -sI \"http://localhost:4000\" | grep \"302\\|Location\"\nHTTP/1.1 302 Found\nLocation: /en\n```\n\nIf a request is made to `/`, it will be redirected to `/en` or `/fr`, depending\non the request locale preference. If the request has no preference between\nsupported locales, it will be redirected to the first locale, `/en` in this\ncase.\n\nLicense\n-------\n\n`PlugLocaleRootRedirect` is © 2017-2019 [Rémi Prévost](http://exomel.com) and may be\nfreely distributed under the [MIT license](https://github.com/remiprev/plug_locale_root_redirect/blob/master/LICENSE.md). See the\n`LICENSE.md` file for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremi%2Fplug_locale_root_redirect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremi%2Fplug_locale_root_redirect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremi%2Fplug_locale_root_redirect/lists"}