Externalize strings in upload page

This commit is contained in:
Eike Kettner 2021-04-01 00:47:33 +02:00
parent 12cad398ac
commit 968c8e02b7
14 changed files with 222 additions and 73 deletions

View File

@ -139,13 +139,13 @@ mainContent model =
viewRegister texts model
UploadPage mid ->
viewUpload mid model
viewUpload texts mid model
NewInvitePage ->
viewNewInvite texts model
ItemDetailPage id ->
viewItemDetail id model
viewItemDetail texts id model
)
@ -476,8 +476,8 @@ viewNewInvite texts model =
]
viewUpload : Maybe String -> Model -> List (Html Msg)
viewUpload mid model =
viewUpload : Messages -> Maybe String -> Model -> List (Html Msg)
viewUpload texts mid model =
[ Html.map UploadMsg
(Upload.viewSidebar
mid
@ -487,7 +487,8 @@ viewUpload mid model =
model.uploadModel
)
, Html.map UploadMsg
(Upload.viewContent mid
(Upload.viewContent texts.upload
mid
model.flags
model.uiSettings
model.uploadModel
@ -495,21 +496,21 @@ viewUpload mid model =
]
viewItemDetail : String -> Model -> List (Html Msg)
viewItemDetail id model =
viewItemDetail : Messages -> String -> Model -> List (Html Msg)
viewItemDetail texts id model =
let
inav =
Page.Home.Data.itemNav id model.homeModel
in
[ Html.map ItemDetailMsg
(ItemDetail.viewSidebar
(ItemDetail.viewSidebar texts.itemDetail
model.sidebarVisible
model.flags
model.uiSettings
model.itemDetailModel
)
, Html.map ItemDetailMsg
(ItemDetail.viewContent
(ItemDetail.viewContent texts.itemDetail
inav
model.flags
model.uiSettings

View File

@ -18,6 +18,7 @@ import File.Select
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Messages.DropzoneComp exposing (Texts)
import Styles as S
import Util.Html exposing (onDragEnter, onDragLeave, onDragOver, onDropFiles)
@ -124,8 +125,8 @@ filterMime model files =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
div
[ classList
[ ( "bg-opacity-100 bg-blue-100 dark:bg-lightblue-800", model.state.hover )
@ -144,24 +145,23 @@ view2 model =
]
[ i [ class "fa fa-mouse-pointer" ] []
, div [ class "ml-3" ]
[ text "Drop files here"
[ text texts.dropFilesHere
]
]
, B.horizontalDivider
{ label = "Or"
{ label = texts.or
, topCss = "w-2/3 mb-4 hidden md:inline-flex"
, labelCss = "px-4 bg-gray-200 bg-opacity-50"
, lineColor = "bg-gray-300 dark:bg-bluegray-600"
}
, B.primaryBasicButton
{ label = "Select ..."
{ label = texts.select
, icon = "fa fa-folder-open font-thin"
, handler = onClick PickFiles
, attrs = [ href "#" ]
, disabled = not model.state.active
}
, div [ class "text-center opacity-75 text-sm mt-4" ]
[ text "Choose document files (pdf, docx, txt, html, ). "
, text "Archives (zip and eml) are extracted."
[ text texts.selectInfo
]
]

View File

@ -13,6 +13,7 @@ import Data.Flags exposing (Flags)
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Messages.ItemDetailComp exposing (Texts)
import Page exposing (Page(..))
@ -30,6 +31,6 @@ update =
Comp.ItemDetail.Update.update
view2 : ItemNav -> UiSettings -> Model -> Html Msg
view2 : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
view2 =
Comp.ItemDetail.View2.view

View File

@ -3,20 +3,20 @@ module Comp.ItemDetail.AddFilesForm exposing (view)
import Comp.Dropzone
import Comp.ItemDetail.Model exposing (..)
import Comp.Progress
import Data.DropdownStyle
import Dict
import File exposing (File)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Html.Events exposing (onClick)
import Messages.ItemDetail.AddFilesForm exposing (Texts)
import Set
import Styles as S
import Util.File exposing (makeFileId)
import Util.Size
view : Model -> Html Msg
view model =
view : Texts -> Model -> Html Msg
view texts model =
div
[ classList
[ ( "hidden", not model.addFilesOpen )
@ -28,7 +28,7 @@ view model =
[ text "Add more files to this item"
]
, Html.map AddFilesMsg
(Comp.Dropzone.view2 model.addFilesModel)
(Comp.Dropzone.view2 texts.dropzone model.addFilesModel)
, div [ class "flex flex-row space-x-2 mt-2" ]
[ button
[ class S.primaryButton

View File

@ -23,17 +23,18 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.ItemDetailComp exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.Time
view : ItemNav -> UiSettings -> Model -> Html Msg
view inav settings model =
view : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
view texts inav settings model =
div [ class "flex flex-col h-full" ]
[ header settings model
, menuBar inav settings model
, body inav settings model
, body texts inav settings model
, itemModal model
]
@ -194,20 +195,20 @@ menuBar inav settings model =
}
body : ItemNav -> UiSettings -> Model -> Html Msg
body inav settings model =
body : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
body texts _ settings model =
div [ class "grid gap-2 grid-cols-1 md:grid-cols-3 h-full" ]
[ leftArea settings model
[ leftArea texts settings model
, rightArea settings model
]
leftArea : UiSettings -> Model -> Html Msg
leftArea settings model =
leftArea : Texts -> UiSettings -> Model -> Html Msg
leftArea texts settings model =
div [ class "w-full md:order-first md:mr-2 flex flex-col" ]
[ addDetailForm settings model
, sendMailForm settings model
, Comp.ItemDetail.AddFilesForm.view model
, Comp.ItemDetail.AddFilesForm.view texts.addFilesForm model
, Comp.ItemDetail.Notes.view model
, div
[ classList

View File

@ -7,8 +7,11 @@ module Messages exposing
import Messages.App
import Messages.CollectiveSettingsPage
import Messages.ItemDetailPage
import Messages.LoginPage
import Messages.NewInvitePage
import Messages.RegisterPage
import Messages.UploadPage
import UiLanguage exposing (UiLanguage(..))
@ -23,6 +26,9 @@ type alias Messages =
, collectiveSettings : Messages.CollectiveSettingsPage.Texts
, login : Messages.LoginPage.Texts
, register : Messages.RegisterPage.Texts
, newInvite : Messages.NewInvitePage.Texts
, upload : Messages.UploadPage.Texts
, itemDetail : Messages.ItemDetailPage.Texts
}
@ -79,6 +85,9 @@ gb =
, collectiveSettings = Messages.CollectiveSettingsPage.gb
, login = Messages.LoginPage.gb
, register = Messages.RegisterPage.gb
, newInvite = Messages.NewInvitePage.gb
, upload = Messages.UploadPage.gb
, itemDetail = Messages.ItemDetailPage.gb
}
@ -92,4 +101,7 @@ de =
, collectiveSettings = Messages.CollectiveSettingsPage.de
, login = Messages.LoginPage.de
, register = Messages.RegisterPage.de
, newInvite = Messages.NewInvitePage.de
, upload = Messages.UploadPage.de
, itemDetail = Messages.ItemDetailPage.de
}

View File

@ -0,0 +1,20 @@
module Messages.DropzoneComp exposing (..)
type alias Texts =
{ dropFilesHere : String
, or : String
, select : String
, selectInfo : String
}
gb : Texts
gb =
{ dropFilesHere = "Drop files here"
, or = "Or"
, select = "Select ..."
, selectInfo =
"Choose document files (pdf, docx, txt, html, ). "
++ "Archives (zip and eml) are extracted."
}

View File

@ -0,0 +1,12 @@
module Messages.ItemDetail.AddFilesForm exposing (..)
import Messages.DropzoneComp
type alias Texts =
{ dropzone : Messages.DropzoneComp.Texts }
gb : Texts
gb =
{ dropzone = Messages.DropzoneComp.gb }

View File

@ -0,0 +1,14 @@
module Messages.ItemDetailComp exposing (..)
import Messages.ItemDetail.AddFilesForm
type alias Texts =
{ addFilesForm : Messages.ItemDetail.AddFilesForm.Texts
}
gb : Texts
gb =
{ addFilesForm = Messages.ItemDetail.AddFilesForm.gb
}

View File

@ -0,0 +1,21 @@
module Messages.ItemDetailPage exposing (..)
import Messages.ItemDetailComp
type alias Texts =
{ itemDetail : Messages.ItemDetailComp.Texts
, editMetadata : String
}
gb : Texts
gb =
{ itemDetail = Messages.ItemDetailComp.gb
, editMetadata = "Edit Metadata"
}
de : Texts
de =
gb

View File

@ -31,3 +31,8 @@ gb =
Creating an invite requires providing the password
from the configuration."""
}
de : Texts
de =
gb

View File

@ -0,0 +1,62 @@
module Messages.UploadPage exposing (..)
import Messages.Basics
import Messages.DropzoneComp
type alias Texts =
{ basics : Messages.Basics.Texts
, dropzone : Messages.DropzoneComp.Texts
, reset : String
, allFilesOneItem : String
, skipExistingFiles : String
, language : String
, languageInfo : String
, uploadErrorMessage : String
, successBox :
{ allFilesUploaded : String
, line1 : String
, itemsPage : String
, line2 : String
, processingPage : String
, line3 : String
, resetLine1 : String
, reset : String
, resetLine2 : String
}
, selectedFiles : String
}
gb : Texts
gb =
{ basics = Messages.Basics.gb
, dropzone = Messages.DropzoneComp.gb
, reset = "Reset"
, allFilesOneItem = "All files are one single item"
, skipExistingFiles = "Skip files already present in docspell"
, language = "Language"
, languageInfo =
"Used for text extraction and analysis. The collective's "
++ "default language is used if not specified here."
, uploadErrorMessage = "There were errors uploading some files."
, successBox =
{ allFilesUploaded = "All files uploaded"
, line1 =
"Your files have been successfully uploaded. "
++ "They are now being processed. Check the "
, itemsPage = "Items Page"
, line2 = " later where the files will arrive eventually. Or go to the "
, processingPage = "Processing Page"
, line3 = " to view the current processing state."
, resetLine1 = " Click "
, reset = "Reset"
, resetLine2 = " to upload more files."
}
, selectedFiles = "Selected Files"
}
de : Texts
de =
gb

View File

@ -11,12 +11,13 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.ItemDetailPage exposing (Texts)
import Page.ItemDetail.Data exposing (..)
import Styles as S
viewSidebar : Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar visible _ settings model =
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ settings model =
div
[ id "sidebar"
, class S.sidebar
@ -28,7 +29,7 @@ viewSidebar visible _ settings model =
, class "font-bold mt-2"
]
[ i [ class "fa fa-pencil-alt mr-2" ] []
, text "Edit Metadata"
, text texts.editMetadata
]
, MB.viewSide
{ start =
@ -52,12 +53,12 @@ viewSidebar visible _ settings model =
]
viewContent : ItemNav -> Flags -> UiSettings -> Model -> Html Msg
viewContent inav _ settings model =
viewContent : Texts -> ItemNav -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts inav _ settings model =
div
[ id "content"
, class S.content
]
[ Html.map ItemDetailMsg
(Comp.ItemDetail.view2 inav settings model.detail)
(Comp.ItemDetail.view2 texts.itemDetail inav settings model.detail)
]

View File

@ -11,6 +11,7 @@ import File exposing (File)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick)
import Messages.UploadPage exposing (Texts)
import Page exposing (Page(..))
import Page.Upload.Data exposing (..)
import Styles as S
@ -28,8 +29,8 @@ viewSidebar _ _ _ _ _ =
[]
viewContent : Maybe String -> Flags -> UiSettings -> Model -> Html Msg
viewContent mid _ _ model =
viewContent : Texts -> Maybe String -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts mid _ _ model =
div
[ id "content"
, class S.content
@ -37,11 +38,11 @@ viewContent mid _ _ model =
[ div [ class "container mx-auto" ]
[ div [ class "px-0 flex flex-col" ]
[ div [ class "py-4" ]
[ renderForm model
[ renderForm texts model
]
, div [ class "py-0" ]
[ Html.map DropzoneMsg
(Comp.Dropzone.view2 model.dropzone)
(Comp.Dropzone.view2 texts.dropzone model.dropzone)
]
, div [ class "py-4" ]
[ a
@ -49,7 +50,7 @@ viewContent mid _ _ model =
, href "#"
, onClick SubmitUpload
]
[ text "Submit"
[ text texts.basics.submit
]
, a
[ class S.secondaryButton
@ -57,19 +58,19 @@ viewContent mid _ _ model =
, href "#"
, onClick Clear
]
[ text "Reset"
[ text texts.reset
]
]
]
, renderErrorMsg model
, renderSuccessMsg (Util.Maybe.nonEmpty mid) model
, renderUploads model
, renderErrorMsg texts model
, renderSuccessMsg texts (Util.Maybe.nonEmpty mid) model
, renderUploads texts model
]
]
renderForm : Model -> Html Msg
renderForm model =
renderForm : Texts -> Model -> Html Msg
renderForm texts model =
div [ class "row" ]
[ Html.form [ action "#" ]
[ div [ class "flex flex-col mb-3" ]
@ -81,7 +82,7 @@ renderForm model =
, class S.radioInput
]
[]
, span [ class "ml-2" ] [ text "Incoming" ]
, span [ class "ml-2" ] [ text texts.basics.incoming ]
]
, label [ class "inline-flex items-center" ]
[ input
@ -91,7 +92,7 @@ renderForm model =
, class S.radioInput
]
[]
, span [ class "ml-2" ] [ text "Outgoing" ]
, span [ class "ml-2" ] [ text texts.basics.outgoing ]
]
]
, div [ class "flex flex-col mb-3" ]
@ -104,7 +105,7 @@ renderForm model =
]
[]
, span [ class "ml-2" ]
[ text "All files are one single item"
[ text texts.allFilesOneItem
]
]
]
@ -118,13 +119,13 @@ renderForm model =
]
[]
, span [ class "ml-2" ]
[ text "Skip files already present in docspell"
[ text texts.skipExistingFiles
]
]
]
, div [ class "flex flex-col mb-3" ]
[ label [ class "inline-flex items-center mb-2" ]
[ span [ class "mr-2" ] [ text "Language:" ]
[ span [ class "mr-2" ] [ text (texts.language ++ ":") ]
, Html.map LanguageMsg
(Comp.FixedDropdown.viewStyled2
(DS.mainStyleWith "w-40")
@ -134,30 +135,29 @@ renderForm model =
)
]
, div [ class "text-gray-400 text-xs" ]
[ text "Used for text extraction and analysis. The collective's "
, text "default language is used if not specified here."
[ text texts.languageInfo
]
]
]
]
renderErrorMsg : Model -> Html Msg
renderErrorMsg model =
renderErrorMsg : Texts -> Model -> Html Msg
renderErrorMsg texts model =
div
[ class "row"
, classList [ ( "hidden", not (isDone model && hasErrors model) ) ]
]
[ div [ class "mt-4" ]
[ div [ class S.errorMessage ]
[ text "There were errors uploading some files."
[ text texts.uploadErrorMessage
]
]
]
renderSuccessMsg : Bool -> Model -> Html Msg
renderSuccessMsg public model =
renderSuccessMsg : Texts -> Bool -> Model -> Html Msg
renderSuccessMsg texts public model =
div
[ class "row"
, classList [ ( "hidden", List.isEmpty model.files || not (isSuccessAll model) ) ]
@ -167,47 +167,46 @@ renderSuccessMsg public model =
[ h3 [ class S.header2, class "text-green-800 dark:text-lime-800" ]
[ i [ class "fa fa-smile font-thin" ] []
, span [ class "ml-2" ]
[ text "All files uploaded"
[ text texts.successBox.allFilesUploaded
]
]
, p
[ classList [ ( "hidden", public ) ]
]
[ text "Your files have been successfully uploaded. "
, text "They are now being processed. Check the "
[ text texts.successBox.line1
, a
[ class S.successMessageLink
, Page.href HomePage
]
[ text "Items page"
[ text texts.successBox.itemsPage
]
, text " later where the files will arrive eventually. Or go to the "
, text texts.successBox.line2
, a
[ class S.successMessageLink
, Page.href QueuePage
]
[ text "Processing Page"
[ text texts.successBox.processingPage
]
, text " to view the current processing state."
, text texts.successBox.line3
]
, p []
[ text "Click "
[ text texts.successBox.resetLine1
, a
[ class S.successMessageLink
, href "#"
, onClick Clear
]
[ text "Reset"
[ text texts.successBox.reset
]
, text " to upload more files."
, text texts.successBox.resetLine2
]
]
]
]
renderUploads : Model -> Html Msg
renderUploads model =
renderUploads : Texts -> Model -> Html Msg
renderUploads texts model =
div
[ class "mt-4"
, classList [ ( "hidden", List.isEmpty model.files || isSuccessAll model ) ]
@ -215,7 +214,7 @@ renderUploads model =
[ div [ class "sixteen wide column" ]
[ div [ class "ui basic segment" ]
[ h2 [ class S.header2 ]
[ text "Selected Files"
[ text texts.selectedFiles
]
, div [ class "ui items" ] <|
if model.singleItem then