Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default language #2

Closed
jakub-zawislak opened this issue Oct 14, 2016 · 0 comments
Closed

Default language #2

jakub-zawislak opened this issue Oct 14, 2016 · 0 comments

Comments

@jakub-zawislak
Copy link

jakub-zawislak commented Oct 14, 2016

I wanted to make english to be default language:

config :polygot,
  locales: %{
    "en" => %{ path_prefix: "" },
    "pl" => %{ path_prefix: "pl" }
  },

It doesn't work. So i modified Polygot.Plug to use language with empty prefix when there is no prefix in route.

defmodule Polygot.Plug do

  #

  def call(conn, _opts) do

    {locale, _} = Enum.find @locales, fn item ->
      {locale, %{path_prefix: prefix}} = item
      prefix == ""
    end

    Gettext.put_locale(@gettext, locale)
    conn |> assign(:locale, locale)
  end

end

It works well in my very small (almost static) app, but I don't know if it's a good solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants