Doesn't work
Closed this issue · 2 comments
jakub-zawislak commented
iex(1)> [info] GET /pl
[info] Sent 500 in 36ms
[error] #PID<0.500.0> running Front.Endpoint terminated
Server: localhost:4010 (http)
Request: GET /pl
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Front.HomeController.init/1
(front) web/controllers/home_controller.ex:2: Front.HomeController.init([action: :index, locale: "pl"])
(front) web/router.ex:1: anonymous fn/1 in Front.Router.match_route/4
(front) lib/phoenix/router.ex:261: Front.Router.dispatch/2
(front) web/router.ex:1: Front.Router.do_call/2
(front) lib/front/endpoint.ex:1: Front.Endpoint.phoenix_pipeline/1
(front) lib/plug/debugger.ex:123: Front.Endpoint."call (overridable 3)"/2
(front) lib/front/endpoint.ex:1: Front.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.6"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:polygot, "~> 0.1.0"}]
end
config :polygot,
locales: %{
"en" => %{ path_prefix: "en" },
"pl" => %{ path_prefix: "pl" }
},
gettext_module: Front.Gettext,
gettext_domain: "default"
def router do
quote do
use Phoenix.Router
import Polygot
end
end
localize get "/", HomeController, :index
$ mix phoenix.routes
home_path GET /en Front.HomeController [action: :index, locale: "en"]
home_path GET /pl Front.HomeController [action: :index, locale: "pl"]
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Polygot.Plug
end
Also Route helpers doesn't work, because it cannot find Polygot.Helpers
. Maybe on hex.pm there is older version of your library?
boudra commented
Hey @Harry27PL,
thanks for the reporting issue, there was a step missing in the readme, here it is:
https://github.com/boudra/polygot#controller
And I put up this fix for the helpers issue c01b52b
please upgrade to the latest and let me know! thanks!
jakub-zawislak commented
Now it works! Thanks