I am developing a multilingual application using the Phoenix Framework
So far, the router looks like this:
scope "/:locale", App do
pipe_through [:browser, :browser_session]
get "/", PageController, :index
get "/otherpage", OtherpageController, :index
end
scope "/", App do
end
I used the plugin in the docs: http://www.phoenixframework.org/docs/understanding-plug#section-module-plugs
And to make the “locale” permanent in the application, I used a custom action in the Phoenix.Controller module to do this:
def action(conn, _) do
apply(__MODULE__, action_name(conn), [conn,
conn.params,
conn.assigns.locale])
end
so now every time I generated a controller, I have to add the above custom action and change each action in the new controller to enter locale
def index(conn, _params, locale) do
list = Repo.all(List)
render conn, "index.html", list: list
end
There are two things that I struggle with:
1 - Is this right? or am I confusing something?
2 - // "/: locale" , : "ru" ?
url: "example.com/en"
Kayne