2021-07-04 08:24:49 +00:00
|
|
|
{-
|
2021-07-25 12:00:11 +00:00
|
|
|
Copyright 2020 Docspell Contributors
|
2021-07-04 08:24:49 +00:00
|
|
|
|
2021-07-25 12:00:11 +00:00
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
2021-07-04 08:24:49 +00:00
|
|
|
-}
|
|
|
|
|
2021-07-25 12:00:11 +00:00
|
|
|
|
2021-03-27 21:00:50 +00:00
|
|
|
module Messages exposing
|
|
|
|
( Messages
|
|
|
|
, fromIso2
|
|
|
|
, get
|
|
|
|
, toIso2
|
|
|
|
)
|
|
|
|
|
|
|
|
import Messages.App
|
2021-04-09 22:30:42 +00:00
|
|
|
import Messages.Page.CollectiveSettings
|
|
|
|
import Messages.Page.Home
|
|
|
|
import Messages.Page.ItemDetail
|
|
|
|
import Messages.Page.Login
|
|
|
|
import Messages.Page.ManageData
|
|
|
|
import Messages.Page.NewInvite
|
|
|
|
import Messages.Page.Queue
|
|
|
|
import Messages.Page.Register
|
|
|
|
import Messages.Page.Upload
|
|
|
|
import Messages.Page.UserSettings
|
2021-04-10 14:13:49 +00:00
|
|
|
import Messages.UiLanguage exposing (UiLanguage(..))
|
2021-03-27 21:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
{-| The messages record contains all strings used in the application.
|
|
|
|
-}
|
|
|
|
type alias Messages =
|
|
|
|
{ lang : UiLanguage
|
|
|
|
, iso2 : String
|
|
|
|
, label : String
|
|
|
|
, flagIcon : String
|
|
|
|
, app : Messages.App.Texts
|
2021-04-09 22:30:42 +00:00
|
|
|
, collectiveSettings : Messages.Page.CollectiveSettings.Texts
|
|
|
|
, login : Messages.Page.Login.Texts
|
|
|
|
, register : Messages.Page.Register.Texts
|
|
|
|
, newInvite : Messages.Page.NewInvite.Texts
|
|
|
|
, upload : Messages.Page.Upload.Texts
|
|
|
|
, itemDetail : Messages.Page.ItemDetail.Texts
|
|
|
|
, queue : Messages.Page.Queue.Texts
|
|
|
|
, userSettings : Messages.Page.UserSettings.Texts
|
|
|
|
, manageData : Messages.Page.ManageData.Texts
|
|
|
|
, home : Messages.Page.Home.Texts
|
2021-03-27 21:00:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get : UiLanguage -> Messages
|
|
|
|
get lang =
|
|
|
|
case lang of
|
|
|
|
English ->
|
|
|
|
gb
|
|
|
|
|
2021-06-05 22:28:35 +00:00
|
|
|
German ->
|
|
|
|
de
|
|
|
|
|
2021-03-27 21:00:50 +00:00
|
|
|
|
|
|
|
{-| Get a ISO-3166-1 code of the given lanugage.
|
|
|
|
-}
|
|
|
|
toIso2 : UiLanguage -> String
|
|
|
|
toIso2 lang =
|
|
|
|
get lang |> .iso2
|
|
|
|
|
|
|
|
|
|
|
|
{-| Return the UiLanguage from given iso2 code. If the iso2 code is not
|
|
|
|
known, return Nothing.
|
|
|
|
-}
|
|
|
|
readIso2 : String -> Maybe UiLanguage
|
|
|
|
readIso2 iso =
|
|
|
|
let
|
|
|
|
isIso lang =
|
|
|
|
iso == toIso2 lang
|
|
|
|
in
|
2021-04-10 14:13:49 +00:00
|
|
|
List.filter isIso Messages.UiLanguage.all
|
2021-03-27 21:00:50 +00:00
|
|
|
|> List.head
|
|
|
|
|
|
|
|
|
|
|
|
{-| return the language from the given iso2 code. if the iso2 code is
|
|
|
|
not known, return English as a default.
|
|
|
|
-}
|
|
|
|
fromIso2 : String -> UiLanguage
|
|
|
|
fromIso2 iso =
|
|
|
|
readIso2 iso
|
|
|
|
|> Maybe.withDefault English
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- Messages Definitions
|
2021-04-10 14:13:49 +00:00
|
|
|
-- for flag icons, see https://github.com/lipis/flag-icon-css
|
|
|
|
-- use two classes: flag-icon flag-icon-xx where xx is the two-letter country code
|
2021-03-27 21:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
gb : Messages
|
|
|
|
gb =
|
|
|
|
{ lang = English
|
|
|
|
, iso2 = "gb"
|
|
|
|
, label = "English"
|
|
|
|
, flagIcon = "flag-icon flag-icon-gb"
|
|
|
|
, app = Messages.App.gb
|
2021-04-09 22:30:42 +00:00
|
|
|
, collectiveSettings = Messages.Page.CollectiveSettings.gb
|
|
|
|
, login = Messages.Page.Login.gb
|
|
|
|
, register = Messages.Page.Register.gb
|
|
|
|
, newInvite = Messages.Page.NewInvite.gb
|
|
|
|
, upload = Messages.Page.Upload.gb
|
|
|
|
, itemDetail = Messages.Page.ItemDetail.gb
|
|
|
|
, queue = Messages.Page.Queue.gb
|
|
|
|
, userSettings = Messages.Page.UserSettings.gb
|
|
|
|
, manageData = Messages.Page.ManageData.gb
|
|
|
|
, home = Messages.Page.Home.gb
|
2021-03-27 21:00:50 +00:00
|
|
|
}
|
2021-06-05 22:28:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
de : Messages
|
|
|
|
de =
|
|
|
|
{ lang = German
|
|
|
|
, iso2 = "de"
|
|
|
|
, label = "Deutsch"
|
|
|
|
, flagIcon = "flag-icon flag-icon-de"
|
|
|
|
, app = Messages.App.de
|
|
|
|
, collectiveSettings = Messages.Page.CollectiveSettings.de
|
2021-06-06 12:10:56 +00:00
|
|
|
, login = Messages.Page.Login.de
|
|
|
|
, register = Messages.Page.Register.de
|
2021-06-06 12:20:06 +00:00
|
|
|
, newInvite = Messages.Page.NewInvite.de
|
2021-06-06 14:57:02 +00:00
|
|
|
, upload = Messages.Page.Upload.de
|
2021-06-06 16:45:10 +00:00
|
|
|
, itemDetail = Messages.Page.ItemDetail.de
|
2021-06-06 18:07:47 +00:00
|
|
|
, queue = Messages.Page.Queue.de
|
2021-06-06 22:47:05 +00:00
|
|
|
, userSettings = Messages.Page.UserSettings.de
|
2021-06-07 07:54:18 +00:00
|
|
|
, manageData = Messages.Page.ManageData.de
|
2021-06-06 11:59:50 +00:00
|
|
|
, home = Messages.Page.Home.de
|
2021-06-05 22:28:35 +00:00
|
|
|
}
|