-
Notifications
You must be signed in to change notification settings - Fork 3
Localisation ekyc #523
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
Open
ayinloya
wants to merge
5
commits into
localisation-biometric-kyc
Choose a base branch
from
localisation-ekyc
base: localisation-biometric-kyc
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−35
Open
Localisation ekyc #523
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5b89e4e
Translate ekyc
ayinloya e1c6665
Translate thank you message
ayinloya dbb50f4
fix loading screen translation
ayinloya 0f70eb9
Merge branch 'localisation-biometric-kyc' into localisation-ekyc
ayinloya 6e5e4af
Merge branch 'localisation-biometric-kyc' into localisation-ekyc
ayinloya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,12 @@ | ||||||||||||||||||||||||||
| import validate from 'validate.js'; | ||||||||||||||||||||||||||
| import '@smileid/web-components/combobox'; | ||||||||||||||||||||||||||
| import '@smileid/web-components/end-user-consent'; | ||||||||||||||||||||||||||
| import { setCurrentLocale } from '@smileid/web-components/localisation'; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| setCurrentLocale, | ||||||||||||||||||||||||||
| translate, | ||||||||||||||||||||||||||
| translateHtml, | ||||||||||||||||||||||||||
| getDirection, | ||||||||||||||||||||||||||
| } from '@smileid/web-components/localisation'; | ||||||||||||||||||||||||||
| import { version as sdkVersion } from '../../package.json'; | ||||||||||||||||||||||||||
| import { getHeaders } from './request'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -110,6 +115,19 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| function applyPageTranslations() { | ||||||||||||||||||||||||||
| document.querySelectorAll('[data-i18n]').forEach((el) => { | ||||||||||||||||||||||||||
| const key = el.getAttribute('data-i18n'); | ||||||||||||||||||||||||||
| if (key) { | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| el.textContent = translate(key); | ||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||
| console.error(`Translation failed for key: ${key}`, e); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| window.addEventListener( | ||||||||||||||||||||||||||
| 'message', | ||||||||||||||||||||||||||
| async (event) => { | ||||||||||||||||||||||||||
|
|
@@ -119,7 +137,11 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| event.data.includes('SmileIdentity::Configuration') | ||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||
| config = JSON.parse(event.data); | ||||||||||||||||||||||||||
| setCurrentLocale(config.translation?.language || 'en'); | ||||||||||||||||||||||||||
| await setCurrentLocale(config.translation?.language || 'en'); | ||||||||||||||||||||||||||
| document.documentElement.dir = getDirection(); | ||||||||||||||||||||||||||
| applyPageTranslations(); | ||||||||||||||||||||||||||
| document.querySelector('main').hidden = false; | ||||||||||||||||||||||||||
|
Comment on lines
+140
to
+143
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: If
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| LoadingScreen.querySelector('.credits').hidden = | ||||||||||||||||||||||||||
| config.hide_attribution; | ||||||||||||||||||||||||||
| const attributions = document.querySelectorAll('.credits'); | ||||||||||||||||||||||||||
|
|
@@ -260,7 +282,9 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| selectIDType.innerHTML = ''; | ||||||||||||||||||||||||||
| const initialOption = document.createElement('option'); | ||||||||||||||||||||||||||
| initialOption.setAttribute('value', ''); | ||||||||||||||||||||||||||
| initialOption.textContent = '--Please Select--'; | ||||||||||||||||||||||||||
| initialOption.textContent = translate( | ||||||||||||||||||||||||||
| 'pages.idSelection.placeholder', | ||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||
| selectIDType.appendChild(initialOption); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ACTION: Load ID Types as <option>s | ||||||||||||||||||||||||||
|
|
@@ -519,10 +543,10 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| autocomplete.setAttribute('id', 'bank_code'); | ||||||||||||||||||||||||||
| autocomplete.innerHTML = ` | ||||||||||||||||||||||||||
| <smileid-combobox-trigger | ||||||||||||||||||||||||||
| label="Search Bank"> | ||||||||||||||||||||||||||
| label="${translate('pages.idInfo.searchBank')}"> | ||||||||||||||||||||||||||
| </smileid-combobox-trigger> | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| <smileid-combobox-listbox empty-label="No bank found"> | ||||||||||||||||||||||||||
| <smileid-combobox-listbox empty-label="${translate('pages.idInfo.noBankFound')}"> | ||||||||||||||||||||||||||
| ${bankCodes | ||||||||||||||||||||||||||
| .map( | ||||||||||||||||||||||||||
| (bank) => | ||||||||||||||||||||||||||
|
|
@@ -647,6 +671,24 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| validationMessages.forEach((el) => el.remove()); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Map field names to their translation keys | ||||||||||||||||||||||||||
| const fieldTranslationKeys = { | ||||||||||||||||||||||||||
| id_number: 'pages.idInfo.idNumber', | ||||||||||||||||||||||||||
| first_name: 'pages.idInfo.firstName', | ||||||||||||||||||||||||||
| last_name: 'pages.idInfo.lastName', | ||||||||||||||||||||||||||
| day: 'pages.idInfo.day', | ||||||||||||||||||||||||||
| month: 'pages.idInfo.month', | ||||||||||||||||||||||||||
| year: 'pages.idInfo.year', | ||||||||||||||||||||||||||
| citizenship: 'pages.idInfo.citizenship', | ||||||||||||||||||||||||||
| bank_code: 'pages.idInfo.bank', | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| function getTranslatedValidationMessage(field) { | ||||||||||||||||||||||||||
| const fieldKey = fieldTranslationKeys[field]; | ||||||||||||||||||||||||||
| const fieldLabel = fieldKey ? translate(fieldKey) : field; | ||||||||||||||||||||||||||
| return translateHtml('pages.validation.isRequired', { field: fieldLabel }); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| function validateInputs(payload) { | ||||||||||||||||||||||||||
| const validationConstraints = {}; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -763,7 +805,7 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| const errorDiv = document.createElement('div'); | ||||||||||||||||||||||||||
| errorDiv.setAttribute('id', `${field}-hint`); | ||||||||||||||||||||||||||
| errorDiv.setAttribute('class', 'validation-message'); | ||||||||||||||||||||||||||
| errorDiv.textContent = errors[field][0]; | ||||||||||||||||||||||||||
| errorDiv.textContent = getTranslatedValidationMessage(field); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| input.insertAdjacentElement('afterend', errorDiv); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
@@ -853,7 +895,13 @@ import { getHeaders } from './request'; | |||||||||||||||||||||||||
| productConstraints[id_info.country].id_types[id_info.id_type].label; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const thankYouMessage = CompleteScreen.querySelector('#thank-you-message'); | ||||||||||||||||||||||||||
| thankYouMessage.textContent = `We will process your ${countryName} - ${idTypeName} information to verify your identity`; | ||||||||||||||||||||||||||
| thankYouMessage.textContent = translateHtml( | ||||||||||||||||||||||||||
| 'pages.complete.processingInfo', | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| country: countryName, | ||||||||||||||||||||||||||
| idType: idTypeName, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| setActiveScreen(CompleteScreen); | ||||||||||||||||||||||||||
| handleSuccess(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Using
textContentwill remove any child HTML elements (like icons or nested spans). This could break UI components that contain both text and HTML. Consider checking if the element has child nodes before replacing content, or use a data attribute to mark text-only elements. [possible issue, importance: 9]