mirror of
https://github.com/ClaperCo/Claper.git
synced 2025-12-16 11:57:58 +01:00
feat: add configurable language support via LANGUAGES environment variable
This commit is contained in:
@@ -39,6 +39,7 @@ MAIL_FROM_NAME=Claper
|
||||
#ALLOW_UNLINK_EXTERNAL_PROVIDER=false
|
||||
#LOGOUT_REDIRECT_URL=https://google.com
|
||||
#GS_JPG_RESOLUTION=300x300
|
||||
#LANGUAGES=en,fr,es,it,nl,de
|
||||
|
||||
# OIDC configuration
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
### v.2.4.0
|
||||
|
||||
### Features
|
||||
|
||||
- Add `LANGUAGES` setting to configure available languages in the app
|
||||
|
||||
### Fixes and improvements
|
||||
|
||||
- Upgrade JS dependencies
|
||||
|
||||
@@ -25,7 +25,8 @@ import Split from "split-grid";
|
||||
import { TourGuideClient } from "@sjmc11/tourguidejs/src/Tour";
|
||||
window.moment = moment;
|
||||
|
||||
const supportedLocales = ["en", "fr", "de", "es", "nl", "it"];
|
||||
// Get supported locales from backend configuration or fallback to default list
|
||||
const supportedLocales = window.claperConfig?.supportedLocales || ["en", "fr", "de", "es", "nl", "it"];
|
||||
|
||||
var locale =
|
||||
document.querySelector("html").getAttribute("lang") ||
|
||||
|
||||
@@ -128,6 +128,11 @@ allow_unlink_external_provider =
|
||||
|
||||
logout_redirect_url = get_var_from_path_or_env(config_dir, "LOGOUT_REDIRECT_URL", nil)
|
||||
|
||||
languages =
|
||||
get_var_from_path_or_env(config_dir, "LANGUAGES", "en,fr,es")
|
||||
|> String.split(",")
|
||||
|> Enum.map(&String.trim/1)
|
||||
|
||||
config :claper, :oidc,
|
||||
enabled: oidc_enabled,
|
||||
issuer: oidc_issuer,
|
||||
@@ -166,7 +171,8 @@ config :claper,
|
||||
enable_account_creation: enable_account_creation,
|
||||
email_confirmation: email_confirmation,
|
||||
allow_unlink_external_provider: allow_unlink_external_provider,
|
||||
logout_redirect_url: logout_redirect_url
|
||||
logout_redirect_url: logout_redirect_url,
|
||||
languages: languages
|
||||
|
||||
config :claper, :presentations,
|
||||
max_file_size: max_file_size,
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
</.live_component>
|
||||
<% end %>
|
||||
|
||||
<div class="shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="overflow-hidden sm:rounded-lg">
|
||||
<div class="py-5">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||
{gettext("Personal informations")}
|
||||
@@ -251,16 +251,21 @@
|
||||
{hidden_input(f, :action, name: "action", value: "update_preferences")}
|
||||
<ClaperWeb.Component.Input.select
|
||||
form={f}
|
||||
fieldClass="w-auto!"
|
||||
fieldClass="w-auto! bg-white"
|
||||
labelClass="text-sm font-medium text-gray-500"
|
||||
array={[
|
||||
{"Deutsch", "de"},
|
||||
{"English", "en"},
|
||||
{"Español", "es"},
|
||||
{"Français", "fr"},
|
||||
{"Italiano", "it"},
|
||||
{"Nederlands", "nl"}
|
||||
]}
|
||||
array={
|
||||
[
|
||||
{"Deutsch", "de"},
|
||||
{"English", "en"},
|
||||
{"Español", "es"},
|
||||
{"Français", "fr"},
|
||||
{"Italiano", "it"},
|
||||
{"Nederlands", "nl"}
|
||||
]
|
||||
|> Enum.filter(fn {_name, code} ->
|
||||
code in Application.get_env(:claper, :languages, ["en", "fr", "es"])
|
||||
end)
|
||||
}
|
||||
key={:locale}
|
||||
name={gettext("Language")}
|
||||
/>
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
<link rel="icon" type="image/png" href="/images/favicon.png" />
|
||||
<link phx-track-static rel="stylesheet" href="/assets/app.css" />
|
||||
<link phx-track-static rel="stylesheet" href="/assets/custom.css" />
|
||||
<script>
|
||||
window.claperConfig = {
|
||||
supportedLocales: <%= Jason.encode!(Application.get_env(:claper, :languages, ["en", "fr", "es"])) %>
|
||||
};
|
||||
</script>
|
||||
<script defer phx-track-static type="text/javascript" src="/assets/app.js">
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user