Externalize strings for document language

This commit is contained in:
Eike Kettner 2021-04-02 23:30:51 +02:00
parent dac95e81e6
commit e76d574ea3
9 changed files with 72 additions and 55 deletions

View File

@ -200,7 +200,7 @@ view2 flags texts settings model =
languageCfg =
{ makeOption =
\l ->
{ text = Data.Language.toName l
{ text = texts.languageLabel l
, additional = ""
}
, placeholder = ""

View File

@ -39,6 +39,7 @@ import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Http
import Markdown
import Messages.LanguageData
import Set exposing (Set)
import Styles as S
import Util.Folder exposing (mkFolderOption)
@ -1054,7 +1055,7 @@ viewMetadata2 flags settings model =
}
languageCfg =
{ display = Data.Language.toName
{ display = Messages.LanguageData.gb
, icon = \_ -> Nothing
, style = DS.mainStyleWith "flex-grow mr-2"
}

View File

@ -327,10 +327,10 @@ view2 flags texts settings model =
languageCfg =
{ makeOption =
\a ->
{ text = Data.Language.toName a
{ text = texts.languageLabel a
, additional = ""
}
, placeholder = "Select"
, placeholder = texts.selectPlaceholder
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}

View File

@ -3,7 +3,6 @@ module Data.Language exposing
, all
, fromString
, toIso3
, toName
)
@ -125,55 +124,6 @@ toIso3 lang =
"lav"
toName : Language -> String
toName lang =
case lang of
German ->
"German"
English ->
"English"
French ->
"French"
Italian ->
"Italian"
Spanish ->
"Spanish"
Portuguese ->
"Portuguese"
Czech ->
"Czech"
Danish ->
"Danish"
Finnish ->
"Finnish"
Norwegian ->
"Norwegian"
Swedish ->
"Swedish"
Russian ->
"Russian"
Romanian ->
"Romanian"
Dutch ->
"Dutch"
Latvian ->
"Latvian"
all : List Language
all =
[ German

View File

@ -1,6 +1,8 @@
module Messages.CollectiveSettingsFormComp exposing (..)
import Data.Language exposing (Language)
import Messages.ClassifierSettingsFormComp
import Messages.LanguageData
type alias Texts =
@ -17,6 +19,7 @@ type alias Texts =
, reindexAllDataHelp : String
, autoTagging : String
, startNow : String
, languageLabel : Language -> String
}
@ -39,4 +42,5 @@ gb =
++ "You must type OK before clicking the button to avoid accidental re-indexing."
, autoTagging = "Auto-Tagging"
, startNow = "Start now"
, languageLabel = Messages.LanguageData.gb
}

View File

@ -0,0 +1,52 @@
module Messages.LanguageData exposing (..)
import Data.Language exposing (Language(..))
gb : Language -> String
gb lang =
case lang of
German ->
"German"
English ->
"English"
French ->
"French"
Italian ->
"Italian"
Spanish ->
"Spanish"
Portuguese ->
"Portuguese"
Czech ->
"Czech"
Danish ->
"Danish"
Finnish ->
"Finnish"
Norwegian ->
"Norwegian"
Swedish ->
"Swedish"
Russian ->
"Russian"
Romanian ->
"Romanian"
Dutch ->
"Dutch"
Latvian ->
"Latvian"

View File

@ -1,6 +1,8 @@
module Messages.SourceFormComp exposing (..)
import Data.Language exposing (Language)
import Messages.Basics
import Messages.LanguageData
type alias Texts =
@ -20,6 +22,8 @@ type alias Texts =
, fileFilterInfo : String
, language : String
, languageInfo : String
, languageLabel : Language -> String
, selectPlaceholder : String
}
@ -58,4 +62,6 @@ Specify a file glob to filter files when uploading archives
, languageInfo =
"Used for text extraction and analysis. The collective's "
++ "default language is used if not specified here."
, languageLabel = Messages.LanguageData.gb
, selectPlaceholder = "Select"
}

View File

@ -1,7 +1,9 @@
module Messages.UploadPage exposing (..)
import Data.Language exposing (Language)
import Messages.Basics
import Messages.DropzoneComp
import Messages.LanguageData
type alias Texts =
@ -25,6 +27,7 @@ type alias Texts =
, resetLine2 : String
}
, selectedFiles : String
, languageLabel : Language -> String
}
@ -54,6 +57,7 @@ gb =
, resetLine2 = " to upload more files."
}
, selectedFiles = "Selected Files"
, languageLabel = Messages.LanguageData.gb
}

View File

@ -74,7 +74,7 @@ renderForm : Texts -> Model -> Html Msg
renderForm texts model =
let
languageCfg =
{ display = Data.Language.toName
{ display = texts.languageLabel
, icon = \_ -> Nothing
, style = DS.mainStyleWith "w-40"
}