Skip to content

Commit

Permalink
Add gettext
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Oct 29, 2022
1 parent 40bb743 commit 64b5972
Show file tree
Hide file tree
Showing 210 changed files with 3,302 additions and 5,071 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/pot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Gettext CI

on:
push:
tags:
- v*

jobs:
pot:
name: Create pot files
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 18.1.0 ]

steps:
- uses: actions/checkout@v3

# (1) -> Preparations
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# (2) -> Install dependencies
- name: Install
run: |
npm ci
cd wizard-style-builder
npm install [email protected] [email protected]
# (3) -> Build app and Docker image
- name: Build
run: |
npm run pot
# (4) -> Check prerelease
- name: Check Prerelease
id: check_prerelease
run: |
GITHUB_TAG=`echo $GITHUB_REF | cut -d/ -f3`
if [[ $GITHUB_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::set-output name=is_prerelease::false"
else
echo "::set-output name=is_prerelease::true"
fi
# (5) -> Create release & upload artifacts
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "locale/wizard.pot,locale/registry.pot"
artifactContentType: text/plain
prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
replacesArtifacts: true
38 changes: 14 additions & 24 deletions engine-registry/elm/Registry.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Registry exposing (Model, Msg, PageModel, main)

import Browser exposing (Document, UrlRequest)
import Browser.Navigation as Nav
import Html exposing (Html, a, div, img, li, ul)
import Gettext exposing (gettext)
import Html exposing (Html, a, div, img, li, text, ul)
import Html.Attributes exposing (class, classList, href, src)
import Html.Events exposing (onClick)
import Json.Decode as D
Expand All @@ -23,21 +24,10 @@ import Registry.Pages.Templates as Templates
import Registry.Ports as Ports
import Registry.Routing as Routing
import Registry.Utils exposing (dispatch)
import Shared.Locale exposing (l, lx)
import Shared.Undraw as Undraw
import Url


l_ : String -> AppState -> String
l_ =
l "Registry"


lx_ : String -> AppState -> Html msg
lx_ =
lx "Registry"


main : Program D.Value Model Msg
main =
Browser.application
Expand Down Expand Up @@ -333,8 +323,8 @@ view model =
if not model.appState.valid then
Page.illustratedMessage
{ image = Undraw.bugFixing
, heading = l_ "view.invalid.heading" model.appState
, msg = l_ "view.invalid.msg" model.appState
, heading = gettext "Configuration Error" model.appState.locale
, msg = gettext "The application is not configured correctly and cannot run." model.appState.locale
}

else
Expand Down Expand Up @@ -372,8 +362,8 @@ view model =
NotFoundModel ->
Page.illustratedMessage
{ image = Undraw.pageNotFound
, heading = l_ "view.notFound.heading" model.appState
, msg = l_ "view.notFound.msg" model.appState
, heading = gettext "Not Found" model.appState.locale
, msg = gettext "The page you are looking for does not exist." model.appState.locale
}

html =
Expand All @@ -382,7 +372,7 @@ view model =
[ content ]
]
in
{ title = l_ "view.title" model.appState
{ title = gettext "DSW Registry" model.appState.locale
, body = html
}

Expand All @@ -402,22 +392,22 @@ header model =
[ div [ class "container" ]
[ a [ class "navbar-brand", href <| Routing.toString Routing.Index ]
[ img [ class "logo", src "/img/logo.svg" ] []
, lx_ "header.brandTitle" appState
, text (gettext "DSW Registry" appState.locale)
]
, ul [ class "nav navbar-nav" ]
[ li
[ class "nav-item"
, classList [ ( "active", model.route == Routing.Index ) ]
]
[ a [ href <| Routing.toString Routing.Index, class "nav-link" ]
[ lx_ "header.knowledgeModels" appState ]
[ text (gettext "Knowledge Models" appState.locale) ]
]
, li
[ class "nav-item"
, classList [ ( "active", model.route == Routing.Templates ) ]
]
[ a [ href <| Routing.toString Routing.Templates, class "nav-link" ]
[ lx_ "header.templates" appState ]
[ text (gettext "Document Templates" appState.locale) ]
]
]
, navigation
Expand All @@ -433,14 +423,14 @@ loggedInHeaderNavigation appState =
[ href <| Routing.toString Routing.Organization
, class "nav-link"
]
[ lx_ "loggedInNavigation.profile" appState ]
[ text (gettext "Profile" appState.locale) ]
]
, li [ class "nav-item" ]
[ a
[ onClick <| SetCredentials Nothing
, class "nav-link"
]
[ lx_ "loggedInNavigation.logOut" appState ]
[ text (gettext "Log Out" appState.locale) ]
]
]

Expand All @@ -450,11 +440,11 @@ publicHeaderNavigation appState =
ul [ class "nav navbar-nav ms-auto" ]
[ li [ class "nav-item" ]
[ a [ href <| Routing.toString Routing.Login, class "nav-link" ]
[ lx_ "publicHeaderNavigation.logIn" appState ]
[ text (gettext "Log In" appState.locale) ]
]
, li [ class "nav-item" ]
[ a [ href <| Routing.toString Routing.Signup, class "nav-link" ]
[ lx_ "publicHeaderNavigation.signUp" appState ]
[ text (gettext "Sign Up" appState.locale) ]
]
]

Expand Down
6 changes: 4 additions & 2 deletions engine-registry/elm/Registry/Common/AppState.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Registry.Common.AppState exposing
, setCredentials
)

import Gettext
import Json.Decode as D
import Registry.Common.Credentials exposing (Credentials)
import Registry.Common.Flags as Flags
Expand All @@ -17,6 +18,7 @@ type alias AppState =
, valid : Bool
, credentials : Maybe Credentials
, provisioning : Provisioning
, locale : Gettext.Locale
}


Expand All @@ -41,10 +43,10 @@ init flagsValue =
, flags.provisioning
]
in
AppState flags.apiUrl True flags.credentials provisioning
AppState flags.apiUrl True flags.credentials provisioning Gettext.defaultLocale

Err _ ->
AppState "" False Nothing defaultProvisioning
AppState "" False Nothing defaultProvisioning Gettext.defaultLocale


setCredentials : Maybe Credentials -> AppState -> AppState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,88 +1,8 @@
module Registry.Common.Provisioning.DefaultLocale exposing (locale)

import Dict exposing (Dict)
import Shared.Common.Provisioning.DefaultLocale as SharedLocale


locale : Dict String String
locale =
Dict.fromList
(SharedLocale.locale
++ [ ( "Registry.header.brandTitle", "DSW Registry" )
, ( "Registry.header.knowledgeModels", "Knowledge Models" )
, ( "Registry.header.templates", "Document Templates" )
, ( "Registry.loggedInNavigation.logOut", "Log Out" )
, ( "Registry.loggedInNavigation.profile", "Profile" )
, ( "Registry.publicHeaderNavigation.logIn", "Log In" )
, ( "Registry.publicHeaderNavigation.signUp", "Sign Up" )
, ( "Registry.view.invalid.heading", "Configuration Error" )
, ( "Registry.view.invalid.msg", "The application is not configured correctly and cannot run." )
, ( "Registry.view.notFound.heading", "Not Found" )
, ( "Registry.view.notFound.msg", "The page you are looking for does not exist." )
, ( "Registry.view.title", "DSW Registry" )
, ( "Registry.Pages.ForgottenToken.formView.email.label", "Email" )
, ( "Registry.Pages.ForgottenToken.formView.email.help", "Enter the email you used to register your organization." )
, ( "Registry.Pages.ForgottenToken.formView.header", "Forgotten Token" )
, ( "Registry.Pages.ForgottenToken.formView.submit", "Submit" )
, ( "Registry.Pages.ForgottenToken.success.heading", "Token recovery successful!" )
, ( "Registry.Pages.ForgottenToken.success.msg", "Check your email address for the recovery link." )
, ( "Registry.Pages.ForgottenTokenConfirmation.update.putError", "Unable to recover your organization token." )
, ( "Registry.Pages.ForgottenTokenConfirmation.view.info", "You will use the following token for authentication. Save it to a safe place. You will not be able to see it again." )
, ( "Registry.Pages.ForgottenTokenConfirmation.view.text", "A new token for your organization %s has been generated!" )
, ( "Registry.Pages.ForgottenTokenConfirmation.view.title", "Recovered" )
, ( "Registry.Pages.ForgottenTokenConfirmation.view.token", "Token" )
, ( "Registry.Pages.Index.update.getError", "Unable to get the packages." )
, ( "Registry.Pages.KMDetail.update.getError", "Unable to get the package." )
, ( "Registry.Pages.KMDetail.view.forkOf", "Fork of" )
, ( "Registry.Pages.KMDetail.view.kmId", "Knowledge Model ID" )
, ( "Registry.Pages.KMDetail.view.kmId.copied", "Copied!" )
, ( "Registry.Pages.KMDetail.view.kmId.copy", "Click to copy Knowledge Model ID" )
, ( "Registry.Pages.KMDetail.view.license", "License" )
, ( "Registry.Pages.KMDetail.view.metamodelVersion", "Metamodel version" )
, ( "Registry.Pages.KMDetail.view.otherVersions", "Other versions" )
, ( "Registry.Pages.KMDetail.view.publishedBy", "Published by" )
, ( "Registry.Pages.KMDetail.view.version", "Version" )
, ( "Registry.Pages.Login.update.error", "Login failed." )
, ( "Registry.Pages.Login.view.header", "Log In" )
, ( "Registry.Pages.Login.view.organizationId", "Organization ID" )
, ( "Registry.Pages.Login.view.token", "Token" )
, ( "Registry.Pages.Login.view.logIn", "Log In" )
, ( "Registry.Pages.Login.view.forgottenToken", "Forgot your token?" )
, ( "Registry.Pages.Organization.update.getError", "Unable to get organization detail." )
, ( "Registry.Pages.Organization.update.putError", "Unable to save changes." )
, ( "Registry.Pages.Organization.update.putSuccess", "Your changes have been saved." )
, ( "Registry.Pages.Organization.view.title", "Edit Organization" )
, ( "Registry.Pages.Organization.view.organizationName", "Organization Name" )
, ( "Registry.Pages.Organization.view.description", "Organization Description" )
, ( "Registry.Pages.Organization.view.email", "Email" )
, ( "Registry.Pages.Organization.view.save", "Save" )
, ( "Registry.Pages.Signup.update.postError", "Registration was not successful." )
, ( "Registry.Pages.Signup.success.heading", "Sign up was successful!" )
, ( "Registry.Pages.Signup.success.msg", "Check your email address for the activation link." )
, ( "Registry.Pages.Signup.formView.privacyRead", "I have read %s and %s." )
, ( "Registry.Pages.Signup.formView.privacy", "Privacy" )
, ( "Registry.Pages.Signup.formView.privacyError", "You have to read Privacy and Terms of Service first." )
, ( "Registry.Pages.Signup.formView.termsOfService", "Terms of Service" )
, ( "Registry.Pages.Signup.formView.title", "Sign Up" )
, ( "Registry.Pages.Signup.formView.organizationId", "Organization ID" )
, ( "Registry.Pages.Signup.formView.name", "Organization Name" )
, ( "Registry.Pages.Signup.formView.email", "Email" )
, ( "Registry.Pages.Signup.formView.description", "Organization Description" )
, ( "Registry.Pages.Signup.formView.signUp", "Sign Up" )
, ( "Registry.Pages.SignupConfirmation.update.putError", "Unable to activate your organization account." )
, ( "Registry.Pages.SignupConfirmation.viewOrganization.title", "Activated" )
, ( "Registry.Pages.SignupConfirmation.viewOrganization.activated", "The account for your organization %s has been successfully activated!" )
, ( "Registry.Pages.SignupConfirmation.viewOrganization.tokenInfo", "You will use the following token for authentication. Save it to a safe place. You will not be able to see it again." )
, ( "Registry.Pages.SignupConfirmation.viewOrganization.token", "Token" )
, ( "Registry.Pages.TemplateDetail.update.getError", "Unable to get the template." )
, ( "Registry.Pages.TemplateDetail.view.templateId", "Template ID" )
, ( "Registry.Pages.TemplateDetail.view.templateId.copied", "Copied!" )
, ( "Registry.Pages.TemplateDetail.view.templateId.copy", "Click to copy Template ID" )
, ( "Registry.Pages.TemplateDetail.view.license", "License" )
, ( "Registry.Pages.TemplateDetail.view.metamodelVersion", "Metamodel version" )
, ( "Registry.Pages.TemplateDetail.view.otherVersions", "Other versions" )
, ( "Registry.Pages.TemplateDetail.view.publishedBy", "Published by" )
, ( "Registry.Pages.TemplateDetail.view.version", "Version" )
, ( "Registry.Pages.Templates.update.getError", "Unable to get templates." )
]
)
Dict.empty
26 changes: 8 additions & 18 deletions engine-registry/elm/Registry/Pages/ForgottenToken.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module Registry.Pages.ForgottenToken exposing
import ActionResult exposing (ActionResult(..))
import Form exposing (Form)
import Form.Validate as Validate exposing (Validation)
import Html exposing (Html, div, form, p)
import Gettext exposing (gettext)
import Html exposing (Html, div, form, p, text)
import Html.Attributes exposing (class)
import Html.Events exposing (onSubmit)
import Registry.Common.AppState exposing (AppState)
Expand All @@ -22,20 +23,9 @@ import Registry.Common.View.Page as Page
import Result exposing (Result)
import Shared.Error.ApiError as ApiError exposing (ApiError)
import Shared.Form.FormError exposing (FormError)
import Shared.Locale exposing (l, lx)
import Shared.Undraw as Undraw


l_ : String -> AppState -> String
l_ =
l "Registry.Pages.ForgottenToken"


lx_ : String -> AppState -> Html msg
lx_ =
lx "Registry.Pages.ForgottenToken"


init : Model
init =
{ form = initRecoveryForm
Expand Down Expand Up @@ -125,22 +115,22 @@ successView : AppState -> Html Msg
successView appState =
Page.illustratedMessage
{ image = Undraw.confirmation
, heading = l_ "success.heading" appState
, msg = l_ "success.msg" appState
, heading = gettext "Token recovery successful!" appState.locale
, msg = gettext "Check your email address for the recovery link." appState.locale
}


formView : AppState -> Model -> Html Msg
formView appState model =
div [ class "card card-form bg-light" ]
[ div [ class "card-header" ] [ lx_ "formView.header" appState ]
[ div [ class "card-header" ] [ text (gettext "Forgotten Token" appState.locale) ]
, div [ class "card-body" ]
[ form [ onSubmit <| FormMsg Form.Submit ]
[ FormResult.errorOnlyView model.submitting
, Html.map FormMsg <| FormGroup.input appState model.form "email" <| l_ "formView.email.label" appState
, Html.map FormMsg <| FormGroup.input appState model.form "email" <| gettext "Email" appState.locale
, p [ class "text-muted" ]
[ lx_ "formView.email.help" appState ]
, ActionButton.submit ( l_ "formView.submit" appState, model.submitting )
[ text (gettext "Enter the email you used to register your organization." appState.locale) ]
, ActionButton.submit ( gettext "Submit" appState.locale, model.submitting )
]
]
]
Loading

0 comments on commit 64b5972

Please sign in to comment.