Skip to content

Commit

Permalink
Merge pull request #119 from BBj-Plugins/109_localize
Browse files Browse the repository at this point in the history
#109 localization For The Login Dialog
  • Loading branch information
saadnoor authored Dec 16, 2021
2 parents b98c7bf + d8ce259 commit 6a32524
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 40 deletions.
73 changes: 38 additions & 35 deletions framework/LoginDialog/LoginDialog.bbj
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
use ::BBjWidget/BBjWidget.bbj::BBjWidget
use ::WebKit/util/DynamicLoader.bbj::DynamicLoader
use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/widgets/InputField/InputField.bbj::InputField
use ::WebKit/framework/LoginDialog/SampleAuthProvider.bbj::SampleAuthProvider
use ::AuthKit/profile/GoogleAccountProfile.bbj::GoogleAccountProfile
use ::AuthKit/profile/MicrosoftAccountProfile.bbj::MicrosoftAccountProfile
use ::AuthKit/profile/AccountProfile.bbj::AccountProfile
use ::AuthKit/widgets/GoogleLoginWidget.bbj::GoogleLoginWidget
use ::AuthKit/widgets/MicrosoftLoginWidget.bbj::MicrosoftLoginWidget
use ::AuthKit/totp/TOTP.bbj::TOTP

use ::WebKit/util/DynamicLoader.bbj::DynamicLoader
use ::WebKit/util/ClientUtil.bbj::ClientUtil

use ::WebKit/widgets/InputField/InputField.bbj::InputField
use ::WebKit/widgets/InputField/IFieldReq.bbj::IFieldReq
use ::WebKit/widgets/InputField/DefaultFieldReq.bbj::DefaultFieldReq
use ::WebKit/widgets/InputField/IValidator.bbj::IValidator

use ::WebKit/framework/LoginDialog/SampleAuthProvider.bbj::SampleAuthProvider
use ::WebKit/framework/LoginDialog/IAuthProvider.bbj::IAuthProvider
use ::WebKit/framework/LoginDialog/IAuthRenewPwProvider.bbj::IAuthRenewPwProvider
use ::WebKit/framework/LoginDialog/LoginDialogBuilder.bbj::LoginDialogBuilder
use ::WebKit/framework/LoginDialog/LoginDialogWindow.bbj::LoginDialogWindow

use ::WebKit/widgets/InputField/IValidator.bbj::IValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::UsernameValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::PasswordValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::NewPasswordValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::RepeatPasswordValidator

use ::WebKit/i18n/I18n.bbj::I18n

class public LoginDialog

Expand Down Expand Up @@ -53,8 +55,6 @@ class public LoginDialog
field public BBjString User$ = ""

field private BBjString logoURL$

rem |||||| CONSTRUCTORS ||||||

method public LoginDialog(BBjString title$, IAuthProvider authProvider!)
bbjutils! = new ::BBUtils.bbj::BBUtils()
Expand All @@ -80,8 +80,6 @@ class public LoginDialog

methodend


rem |||||| GETTER & SETTER ||||||
method public void setLogo(BBjString logo$)
#logoURL$ = logo$
methodend
Expand Down Expand Up @@ -112,7 +110,6 @@ class public LoginDialog
#passwordValidator = passwordValidator
methodend

rem |||||| DO MODAL ||||||
method public Boolean doModal()

if #AllowRemember! then
Expand Down Expand Up @@ -172,7 +169,6 @@ class public LoginDialog
return
methodend

rem |||||| CONTENT BUILDERS ||||||
method public void buildLoginContent(LoginDialogWindow wnd!)
#buildLoginContent(wnd!,"")
methodend
Expand All @@ -190,16 +186,18 @@ class public LoginDialog
if #usernameValidator! = null() then #usernameValidator! = new UsernameValidator()
if #passwordValidator! = null() then #passwordValidator! = new PasswordValidator()

LoginDialogBuilder.addUsernameInput(wnd!, #usernameValidator! , user$)
LoginDialogBuilder.addPasswordInput(wnd!, #passwordValidator!, "Password", "Your password")
LoginDialogBuilder.addUsernameInput(wnd!, new UsernameValidator(), user$)
LoginDialogBuilder.addPasswordInput(wnd!, new PasswordValidator(), I18n.getTranslation("password-upper"), I18n.getTranslation("your-password"))
else
LoginDialogBuilder.addUsernameInput(wnd!, null(), user$)
LoginDialogBuilder.addPasswordInput(wnd!, null(), "Password", "Your password")
LoginDialogBuilder.addPasswordInput(wnd!, null(), I18n.getTranslation("password"), I18n.getTranslation("your-password"))
fi

if #AllowRemember! = Boolean.TRUE then LoginDialogBuilder.addRememberMeBox(wnd!)
LoginDialogBuilder.addSubmitButton(wnd!, "Login", "login")

if #AllowRemember! then
LoginDialogBuilder.addRememberMeBox(wnd!)
fi
LoginDialogBuilder.addSubmitButton(wnd!, I18n.getTranslation("login-upper"), I18n.getTranslation("login"))

if #getLoginWithGoogle() OR #getLoginWithMicrosoft() then
LoginDialogBuilder.addSSOZone(wnd!)
if #getLoginWithGoogle() then
Expand All @@ -211,17 +209,19 @@ class public LoginDialog
fi


if #AllowForgotPw! = Boolean.TRUE then LoginDialogBuilder.addRedirect(wnd!, "Forgot your Password?", "gotoForgotPassword")
if #AllowForgotPw! = Boolean.TRUE then
LoginDialogBuilder.addRedirect(wnd!, I18n.getTranslation("forgot-your-password"), "gotoForgotPassword")
fi
methodend

method public void buildForgotPwContent(LoginDialogWindow wnd!, BBjString user$)
LoginDialogBuilder.addLogo(wnd!,#logoURL$)
LoginDialogBuilder.addPageTitle(wnd!,"Request a new password")
LoginDialogBuilder.addPageTitle(wnd!,I18n.getTranslation("request-a-new-password"))
if #isValidationEnabled! = Boolean.TRUE then

if #usernameValidator! = null() then #usernameValidator! = new UsernameValidator()
LoginDialogBuilder.addUsernameInput(wnd!, #usernameValidator! , user$)
LoginDialogBuilder.addPasswordInput(wnd!, #passwordValidator!, "Password", "Your password")
LoginDialogBuilder.addPasswordInput(wnd!, #passwordValidator!, I18n.getTranslation("password"), I18n.getTranslation("your-password"))
else
LoginDialogBuilder.addUsernameInput(wnd!, null(), user$)
fi
Expand All @@ -235,27 +235,30 @@ class public LoginDialog
LoginDialogBuilder.addPageTitle(wnd!,title$)
LoginDialogBuilder.addTextField(wnd!, response$)
if retry! then
LoginDialogBuilder.addSubmitButton(wnd!, "Retry", methodName$)
LoginDialogBuilder.addSubmitButton(wnd!, I18n.getTranslation("retry"), methodName$)
else
LoginDialogBuilder.addSubmitButton(wnd!, "Return to Login", "gotoLogin")
LoginDialogBuilder.addSubmitButton(wnd!, I18n.getTranslation("return-to-login"), "gotoLogin")
endif
methodend

method public void buildNewPwContent(LoginDialogWindow wnd!, BBjString token!)
LoginDialogBuilder.addLogo(wnd!, #logoURL$)
LoginDialogBuilder.addPageTitle(wnd!, "Choose a new password")
LoginDialogBuilder.addPageTitle(wnd!, I18n.getTranslation("choose-a-new-password"))
if #isValidationEnabled! = Boolean.TRUE then
if #passwordValidator! = null() then #passwordValidator! = new NewPasswordValidator()
LoginDialogBuilder.addPasswordInput(wnd!, #passwordValidator!, "New Password", "new password", Boolean.TRUE)
if #passwordValidator! = null() then
#passwordValidator! = new NewPasswordValidator()
newPasswordText! = I18n.getTranslation("new-password")
LoginDialogBuilder.addPasswordInput(wnd!, #passwordValidator!, newPasswordText!, newPasswordText!, Boolean.TRUE)
fi
else
LoginDialogBuilder.addPasswordInput(wnd!, null(), "New Password", "new password", Boolean.TRUE)
fi
LoginDialogBuilder.addRepeatPasswordInput(wnd!, new RepeatPasswordValidator(), "Repeat Password", "repeat password")
LoginDialogBuilder.addSubmitButton(wnd!, "Set Password", "setPasswordWithToken")
fi
repeatPasswordText! = I18n.getTranslation("repeat-password")
LoginDialogBuilder.addRepeatPasswordInput(wnd!, new RepeatPasswordValidator(), repeatPasswordText!, repeatPasswordText!)
LoginDialogBuilder.addSubmitButton(wnd!, I18n.getTranslation("set-password"), "setPasswordWithToken")
methodend



rem |||||| REDIRECTS ||||||
method public void gotoForgotPassword()
if #authRenewPw! = null() then
Expand All @@ -264,7 +267,7 @@ class public LoginDialog
#loginWindow! = null()
endif
#responseWindow! = new LoginDialogWindow(#this!, #loginWrapper!)
#buildResponseContent(#responseWindow!, "", "Something went wrong" ,"It seems you cannot use this functionality.", Boolean.FALSE, "")
#buildResponseContent(#responseWindow!, "", I18n.getTranslation("something-went-wrong") , I18n.getTranslation("it-seems-you-cannot-use-this-functionality"), Boolean.FALSE, "")
else
declare BBjString user$

Expand Down Expand Up @@ -333,7 +336,7 @@ class public LoginDialog
endif

#responseWindow! = new LoginDialogWindow(#this!, #loginWrapper!)
#buildResponseContent(#responseWindow!, username$, "Password token sent" ,response$, Boolean.FALSE, "")
#buildResponseContent(#responseWindow!, username$, I18n.getTranslation("password-token-sent") ,response$, Boolean.FALSE, "")
methodend

method public void setPasswordWithToken(BBjString password$)
Expand All @@ -347,10 +350,10 @@ class public LoginDialog

if response! then
#responseWindow! = new LoginDialogWindow(#this!, #loginWrapper!)
#buildResponseContent(#responseWindow!, username$, "Password been changed" , "You may now login with your new user credentials.", Boolean.FALSE, "")
#buildResponseContent(#responseWindow!, username$, I18n.getTranslation("password-been-changed"), I18n.getTranslation("you-may-now-login-with-your-new-user-credentials"), Boolean.FALSE, "")
else
#responseWindow! = new LoginDialogWindow(#this!, #loginWrapper!)
#buildResponseContent(#responseWindow!, username$, "Something went wrong" , "Password has not been reset. Please try again", Boolean.TRUE, "gotoNewPassword")
#buildResponseContent(#responseWindow!, username$, I18n.getTranslation("something-went-wrong"), I18n.getTranslation("password-has-not-been-reset-please-try-again") , Boolean.TRUE, "gotoNewPassword")
endif

methodend
Expand All @@ -369,4 +372,4 @@ l!.setAllowRemember(Boolean.TRUE)

if l!.doModal() then
a=msgbox(l!.getUser(),0,"SUCCESS")
fi
fi
15 changes: 10 additions & 5 deletions framework/LoginDialog/LoginDialogBuilder.bbj
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
rem use ::WebKit/framework/LoginDialog/LoginDialog.bbj::LoginDialog
use ::BBjWidget/BBjWidget.bbj::BBjWidget

use ::WebKit/framework/LoginDialog/LoginDialogWindow.bbj::LoginDialogWindow
use ::WebKit/widgets/InputField/InputField.bbj::InputField
use ::WebKit/widgets/InputField/extensions/PasswordField.bbj::PasswordField
use ::WebKit/widgets/InputField/extensions/TextField.bbj::TextField
use ::BBjWidget/BBjWidget.bbj::BBjWidget
use ::WebKit/widgets/common/Overlay/Overlay.bbj::Overlay

use ::WebKit/util/ClientUtil.bbj::ClientUtil

use ::WebKit/widgets/InputField/IValidator.bbj::IValidator
Expand All @@ -13,6 +15,8 @@ use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::PasswordValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::NewPasswordValidator
use ::WebKit/framework/LoginDialog/LoginInputValidator.bbj::RepeatPasswordValidator

use ::WebKit/i18n/I18n.bbj::I18n

use ::AuthKit/widgets/GoogleLoginWidget.bbj::GoogleLoginWidget
use ::AuthKit/widgets/MicrosoftLoginWidget.bbj::MicrosoftLoginWidget

Expand Down Expand Up @@ -49,9 +53,9 @@ class public LoginDialogBuilder extends BBjWidget
dialog!.getUsername().setInput(user$)
endif

dialog!.getUsername().setLabel("Username")
dialog!.getUsername().setPlaceHolder("name@company.com")
dialog!.getUsername().setSuffix("user")
dialog!.getUsername().setLabel(I18n.getTranslation("username-upper"))
dialog!.getUsername().setPlaceHolder(I18n.getTranslation("name-company-com"))
dialog!.getUsername().setSuffix(I18n.getTranslation("user"))

rem dialog!.getUsername().getInputField().setCallback(BBjAPI.ON_EDIT_MODIFY, dialog!, "validateUsername")
methodend
Expand Down Expand Up @@ -83,7 +87,8 @@ class public LoginDialogBuilder extends BBjWidget
methodend

method public static void addRememberMeBox(LoginDialogWindow dialog!)
dialog!.setRememberMe(dialog!.getContent().addCheckBox(dialog!.getContent().getAvailableControlID(),0,0,0,0,"Keep me signed in"))
content! = dialog!.getContent()
dialog!.setRememberMe(content!.addCheckBox(content!.getAvailableControlID(),0,0,0,0,I18n.getTranslation("keep-mesigned-in")))
dialog!.getRememberMe().setStyle("margin-top","20px")
dialog!.getRememberMe().setStyle("margin-bottom","20px")

Expand Down
2 changes: 2 additions & 0 deletions framework/PortalFrame/PortalFrame.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use ::WebKit/widgets/Drawer/Drawer.bbj::Drawer
use ::WebKit/model/DrawerMenuTileEntry.bbj::DrawerMenuTileEntry
use ::WebKit/widgets/TilesTextHeader/TilesTextHeader.bbj::TilesTextHeader
use ::WebKit/model/DrawerModel.bbj::DrawerModel

use ::WebKit/i8n/I18n.bbj::I18n
use java.util.HashMap

class public PortalFrame
Expand Down
17 changes: 17 additions & 0 deletions i18n/I18n.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use ::translations/bbtranslator.bbj::BBTranslator

class public I18n

field public static Boolean SelfLearningTranslations! = Boolean.FALSE
field public static BBTranslator Translator! = BBTranslator.getInstance("webkit", STBL("!LOCALE"), "", "WebKit/i18n")

method public static BBjString getTranslation(BBjString key$)
if #SelfLearningTranslations! then
#Translator!.clearCache()
methodret #Translator!.getTranslation(key$,key$,1)
else
methodret #Translator!.getTranslation(key$)
fi
methodend

classend
25 changes: 25 additions & 0 deletions i18n/webkit.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
#Thu Dec 16 15:25:15 CET 2021
choose-a-new-password=Choose a new password
forgot-your-password=Forgot your Password?
it-seems-you-cannot-use-this-functionality=It seems you cannot use this functionality.
keep-mesigned-in=Keep me signed in
login=login
login-upper=Login
name-company-com=name@company.com
new-password=New Password
password=password
password-been-changed=Password has been changed
password-token-sent=Password token sent
password-upper=Password
repeat-password=Repeat Password
request-a-new-password=Request a new password
retry=Retry
return-to-login=Return to Login
send-email=Send Email
set-password=Set Password
something-went-wrong=Something went wrong
user=user
username-upper=Username
you-may-now-login-with-your-new-user-credentials=You may now log in with your new user credentials.
your-password=your password
25 changes: 25 additions & 0 deletions i18n/webkit_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
#Thu Dec 16 15:25:15 CET 2021
choose-a-new-password=W\u00E4hlen Sie ein neues Passwort
forgot-your-password=Passwort vergessen?
it-seems-you-cannot-use-this-functionality=Es scheint, dass Sie diese Funktion nicht nutzen k\u00F6nnen.
keep-mesigned-in=Angemeldet bleiben
login=anmelden
login-upper=Login
name-company-com=name@firma.com
new-password=Neues Password
password=Passwort
password-been-changed=Das Passwort wurde ge\u00E4ndert
password-token-sent=Das Passwort-Token wurde gesendet
password-upper=Passwort
repeat-password=Passwort wiederholen
request-a-new-password=Ein neues Passwort anfordern
retry=Erneut versuchen
return-to-login=Zur\u00C3\u00BCck zum Login
send-email=E-Mail senden
set-password=Passwort festlegen
something-went-wrong=Etwas ist schief gelaufen
user=Benutzer
username-upper=Benutzername
you-may-now-login-with-your-new-user-credentials=Sie k\u00F6nnen sich nun mit Ihren neuen Benutzerdaten anmelden.
your-password=dein Passwort
25 changes: 25 additions & 0 deletions i18n/webkit_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
#Thu Dec 16 15:25:15 CET 2021
choose-a-new-password=Choose a new password
forgot-your-password=Forgot your Password?
it-seems-you-cannot-use-this-functionality=It seems you cannot use this functionality.
keep-mesigned-in=Keep me signed in
login=login
login-upper=Login
name-company-com=name@company.com
new-password=New Password
password=password
password-been-changed=Password has been changed
password-token-sent=Password token sent
password-upper=Password
repeat-password=Repeat Password
request-a-new-password=Request a new password
retry=Retry
return-to-login=Return to Login
send-email=Send Email
set-password=Set Password
something-went-wrong=Something went wrong
user=user
username-upper=Username
you-may-now-login-with-your-new-user-credentials=You may now log in with your new user credentials.
your-password=your password

0 comments on commit 6a32524

Please sign in to comment.