From a115b49b4c21cf54755a2e5fed25dddfa9cee90f Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 17 Nov 2020 15:42:03 +0100 Subject: [PATCH] Only load all locales in prod mode Signed-off-by: Thomas Citharel --- config/config.exs | 20 +------------------- config/dev.exs | 7 ------- config/prod.exs | 25 +++++++++++++++++++++++++ lib/mobilizon/cldr.ex | 6 +++++- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/config/config.exs b/config/config.exs index 01cd4e48..6145a5c8 100644 --- a/config/config.exs +++ b/config/config.exs @@ -181,26 +181,8 @@ config :http_signatures, config :mobilizon, :cldr, locales: [ - "ar", - "be", - "ca", - "cs", - "de", - "en", - "es", - "fi", "fr", - "gl", - "hu", - "it", - "ja", - "nl", - "nn", - "oc", - "pl", - "pt", - "ru", - "sv" + "en" ] config :mobilizon, :activitypub, diff --git a/config/dev.exs b/config/dev.exs index 26576168..a58b0c96 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -92,13 +92,6 @@ config :mobilizon, :instance, # config :mobilizon, :activitypub, sign_object_fetches: false -# No need to compile every locale in development environment -config :mobilizon, :cldr, - locales: [ - "fr", - "en" - ] - config :mobilizon, :anonymous, reports: [ allowed: true diff --git a/config/prod.exs b/config/prod.exs index 5dd0e3b3..5107dc6b 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -13,6 +13,31 @@ config :mobilizon, Mobilizon.Web.Endpoint, # Do not print debug messages in production config :logger, level: :info +# Load all locales in production +config :mobilizon, :cldr, + locales: [ + "ar", + "be", + "ca", + "cs", + "de", + "en", + "es", + "fi", + "fr", + "gl", + "hu", + "it", + "ja", + "nl", + "nn", + "oc", + "pl", + "pt", + "ru", + "sv" + ] + cond do System.get_env("INSTANCE_CONFIG") && File.exists?("./config/#{System.get_env("INSTANCE_CONFIG")}") -> diff --git a/lib/mobilizon/cldr.ex b/lib/mobilizon/cldr.ex index 0188b870..3759211f 100644 --- a/lib/mobilizon/cldr.ex +++ b/lib/mobilizon/cldr.ex @@ -5,6 +5,10 @@ defmodule Mobilizon.Cldr do use Cldr, locales: Application.get_env(:mobilizon, :cldr)[:locales], - gettext: Mobilizon.Web.Gettext, + gettext: + if(Application.fetch_env!(:mobilizon, :env) == :prod, + do: Mobilizon.Web.Gettext, + else: nil + ), providers: [Cldr.Number, Cldr.Calendar, Cldr.DateTime, Cldr.Language] end