WIP language selector

This commit is contained in:
Mayel de Borniol 2021-12-22 20:08:08 +13:00
parent a2f83ac354
commit 7f11c24fec
4 changed files with 30 additions and 5 deletions

View file

@ -7,7 +7,7 @@ Self-host your online community and shape your experience at the most granular l
Empower your community with tools to perform social, economic and political activities. Create safe and private spaces, and connect with the fediverse on your own terms.
### ⚠️ Warning
This project is in the alpha stage. All APIs may change without warning and no guarantees are given about stability. Do not use it in production. You can keep track of progress [in our milestones](https://github.com/bonfire-networks/bonfire-app/milestones)
This project is in the alpha stage. All APIs may change without warning and no guarantees are given about stability. Do not use it in production. You can keep track of progress [in our milestones](https://github.com/bonfire-networks/bonfire-app/milestones?direction=asc&sort=due_date&state=open)
### 🔥 Flavours
This repo includes configurations to run two main [flavours of Bonfire](https://bonfirenetworks.org/use-bonfire/) you can choose from:

View file

@ -1,4 +1,23 @@
import Config
default_locale = "en"
config :bonfire_common,
otp_app: :bonfire
# localisation
config :bonfire,
default_locale: default_locale
# internationalisation
config :bonfire_common, Bonfire.Web.Cldr,
default_locale: default_locale,
locales: ["fr", "en", "es"], # locales that will be made available on top of those for which gettext localisation files are available
providers: [Cldr.Language],
gettext: Bonfire.Web.Gettext,
data_dir: "./priv/cldr",
add_fallback_locales: true,
# precompile_number_formats: ["¤¤#,##0.##"],
# precompile_transliterations: [{:latn, :arab}, {:thai, :latn}]
# force_locale_download: false,
generate_docs: true

View file

@ -3,12 +3,13 @@ let ExtensionHooks = {};
// TODO: make this more configurable? ie. don't import disabled extensions
import { ThemeHooks } from "./../../../assets/js/theme"
import { CommonHooks } from "./../../../forks/bonfire_common/assets/js/extension"
import { InputSelectHooks } from "./../../../assets/js/input_select"
import { GeolocateHooks } from "./../../../deps/bonfire_geolocate/assets/js/extension"
import { KanbanHooks } from "./../../../deps/bonfire_ui_kanban/assets/js/extension"
import { EditorCkHooks } from "./../../../deps/bonfire_editor_ck/assets/js/extension"
import { NotificationsHooks } from "./../../../assets/js/notifications"
Object.assign(ExtensionHooks, ThemeHooks, InputSelectHooks, GeolocateHooks, KanbanHooks, EditorCkHooks, NotificationsHooks)
Object.assign(ExtensionHooks, ThemeHooks, InputSelectHooks, CommonHooks, GeolocateHooks, KanbanHooks, EditorCkHooks, NotificationsHooks)
export { ExtensionHooks }

View file

@ -12,17 +12,22 @@ defmodule Bonfire.Web.Router do
pipeline :browser do
plug :accepts, ["html", "activity+json"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {Bonfire.UI.Social.Web.LayoutView, :root}
plug Cldr.Plug.SetLocale,
default: Bonfire.Web.Localise.default_locale,
apps: [:cldr, :gettext],
from: [:session, :cookie, :accept_language],
gettext: Bonfire.Web.Gettext,
cldr: Bonfire.Web.Cldr
plug :fetch_live_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Bonfire.Web.Plugs.ActivityPub
plug Bonfire.Web.Plugs.LoadCurrentAccount
plug Bonfire.Web.Plugs.LoadCurrentUser
plug Bonfire.Web.Plugs.Locale # TODO: skip guessing a locale if the user has one in preferences
# plug Bonfire.Web.Plugs.Locale # TODO: skip guessing a locale if the user has one in preferences
end
pipeline :guest_only do
plug Bonfire.Web.Plugs.GuestOnly
end