wlminimal

wlminimal

Internationalization: Not working "post" method with set_locale package?

Hi all.
I want to be my website works in 2 locales (en , ko)
so I followed this tutorial
I installed set_locala package
and it will look like this.

in router.ex

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
    plug SetLocale, gettext: TextingWeb.Gettext, default_locale: "ko", cookie_key: "project_locale"
  end

scope "/:locale", TextingWeb do
    pipe_through :browser # Use the default browser stack

    get "/", PageController, :index

    # Sign in and out
    get "/sign-in", AuthController, :new, as: :sign_in
    post "/sign-in", AuthController, :new, as: :sign_in
    get "/sign-out", AuthController, :delete, as: :sign_out
    get "/sign-in/:token", AuthController, :create, as: :sign_in
    get "/sign-up", UserController, :new,  as: :sign_up
    post "/sign-up", UserController, :create, as: :sign_up

    get "/confirm-email", ConfirmEmailController, :new
    post "/confirm-email", ConfirmEmailController, :create

  end

It works ok, It displays other locale (Korean), but when I tried to sign-in, it doesn’t work.
params that I submited from sign-in form ignored,

[debug] Processing with TextingWeb.AuthController.new/2
  Parameters: %{"locale" => "ko"}
  Pipelines: [:browser]

It only returns %{“locale” => “ko”}
how can I work around this?

Marked As Solved

OvermindDL1

OvermindDL1

Ah, in that case it looks like that library has a bug:
https://github.com/smeevil/set_locale/blob/master/lib/set_locale.ex#L42

It appears it only supports converting GET requests, as it will turn any missing locale parameter into a redirected get request, unsure why it does that, seems like it would be better to just inject the locale string into the parameter list of the current request so downstream can pretend it is on the argument list.

Although based on what it’s doing it looks like it could just be replaced by a fairly simple GetText language setting plug inline with the router.

Also Liked

wlminimal

wlminimal

Oh, Thanks, I really appreciate that.

Where Next?

Popular in Questions Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement