Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/1521 language support backport #1524

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ public String authenticate(Map<String, Object> model, HttpServletRequest request
model.put("i18n_EN", i18nService.generateMessages(Locale.ENGLISH));
model.put("i18n_UK", i18nService.generateMessages(new Locale("uk")));
model.put("i18n_RO", i18nService.generateMessages(new Locale("ro")));
model.put("i18n_DE", i18nService.generateMessages(new Locale("de")));
model.put("i18n_FR", i18nService.generateMessages(new Locale("fr")));
model.put("i18n_ES", i18nService.generateMessages(new Locale("es")));
model.put("operationHash", operationSessionService.generateOperationHash(operationId));
model.put("showAndroidSecurityWarning", webFlowConfig.getShowAndroidSecurityWarning());
model.put("usernameMaxLength", webFlowConfig.getUsernameMaxLength());
Expand Down
24 changes: 21 additions & 3 deletions powerauth-webflow/src/main/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,31 @@ import enLocaleData from "react-intl/locale-data/en";
import csLocaleData from "react-intl/locale-data/cs";
import ukLocaleData from "react-intl/locale-data/uk";
import roLocaleData from "react-intl/locale-data/ro";
import deLocaleData from "react-intl/locale-data/de";
import frLocaleData from "react-intl/locale-data/fr";
import esLocaleData from "react-intl/locale-data/es";

// currently only EN and CS languages are supported

// currently specific languages are supported
addLocaleData([
...enLocaleData,
...csLocaleData,
...ukLocaleData,
...roLocaleData
...roLocaleData,
...deLocaleData,
...frLocaleData,
...esLocaleData

]);
const languagesMapping = [
{"code":"en", "country" : "US"},
{"code":"cs", "country" : "CZ"},
{"code":"ro", "country" : "RO"},
{"code":"uk", "country" : "UA"}
{"code":"uk", "country" : "UA"},
{"code":"de", "country" : "DE"},
{"code":"fr", "country" : "FR"},
{"code":"es", "country" : "ES"}

];

// check if language is supported
Expand Down Expand Up @@ -93,6 +105,12 @@ if (msie && msie < 9) {
window.alert(I18N_UK.messages["browser.unsupported"]);
} else if (lang === "ro") {
window.alert(I18N_RO.messages["browser.unsupported"]);
} else if (lang === "de") {
window.alert(I18N_DE.messages["browser.unsupported"]);
} else if (lang === "fr") {
window.alert(I18N_FR.messages["browser.unsupported"]);
} else if (lang === "es") {
window.alert(I18N_ES.messages["browser.unsupported"]);
} else {
window.alert(I18N_EN.messages["browser.unsupported"]);
}
Expand Down
5 changes: 4 additions & 1 deletion powerauth-webflow/src/main/js/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export class App extends React.Component {
{"code":"en", "country" : "US"},
{"code":"cs", "country" : "CZ"},
{"code":"ro", "country" : "RO"},
{"code":"uk", "country" : "UA"}
{"code":"uk", "country" : "UA"},
{"code":"de", "country" : "DE"},
{"code":"fr", "country" : "FR"},
{"code":"es", "country" : "ES"}
];
}

Expand Down
7 changes: 7 additions & 0 deletions powerauth-webflow/src/main/js/reducers/localeReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ export default function reducer(state = {locale: I18N_EN.locale, messages: I18N_
return {...state, locale: I18N_UK.locale, messages: I18N_UK.messages};
} else if (action.locale === "ro") {
return {...state, locale: I18N_RO.locale, messages: I18N_RO.messages};
} else if (action.locale === "de") {
return {...state, locale: I18N_DE.locale, messages: I18N_DE.messages};
} else if (action.locale === "fr") {
return {...state, locale: I18N_FR.locale, messages: I18N_FR.messages};
} else if (action.locale === "es") {
return {...state, locale: I18N_ES.locale, messages: I18N_ES.messages};
}


return state;
default:
return state;
Expand Down
4 changes: 4 additions & 0 deletions powerauth-webflow/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
var I18N_CS = {locale: 'cs', messages: JSON.parse(/*[[${i18n_CS}]]*/)};
var I18N_UK = {locale: 'uk', messages: JSON.parse(/*[[${i18n_UK}]]*/)};
var I18N_RO = {locale: 'ro', messages: JSON.parse(/*[[${i18n_RO}]]*/)};
var I18N_DE = {locale: 'de', messages: JSON.parse(/*[[${i18n_DE}]]*/)};
var I18N_FR = {locale: 'fr', messages: JSON.parse(/*[[${i18n_FR}]]*/)};
var I18N_ES = {locale: 'es', messages: JSON.parse(/*[[${i18n_ES}]]*/)};


var csrf = {headerName: [[${_csrf.headerName}]], token: [[${_csrf.token}]]};

Expand Down
Loading