Set default LOCALE

This commit is contained in:
Adrian Kumpf
2019-09-02 10:57:25 +02:00
parent a035f6d31e
commit d0cec8435d
4 changed files with 11 additions and 3 deletions

View File

@@ -18,4 +18,6 @@ config :logger, :console,
config :phoenix, :json_library, Jason
config :gettext, :default_locale, "en"
import_config "#{Mix.env()}.exs"

View File

@@ -4,9 +4,15 @@ defmodule Util do
def random_encoded_bytes do
:crypto.strong_rand_bytes(64) |> Base.encode64()
end
def validate_locale!("en"), do: "en"
def validate_locale!("de"), do: "de"
def validate_locale!(lang), do: raise("Unsopported locale #{inspect(lang)}")
end
config :gettext, :default_locale, System.get_env("LOCALE")
config :gettext,
:default_locale,
System.get_env("LOCALE", "en") |> Util.validate_locale!()
config :teslamate, TeslaMate.Repo,
username: System.fetch_env!("DATABASE_USER"),

View File

@@ -43,7 +43,7 @@ defmodule TeslaMate.Locations.Geocoder do
end
defp lang do
Application.get_env(:gettext, :default_locale, "en")
Application.fetch_env!(:gettext, :default_locale)
end
# Address Formatting

View File

@@ -4,7 +4,7 @@ defmodule TeslaMate.MixProject do
def project do
[
app: :teslamate,
version: "1.7.0",
version: "1.8.0-beta",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),