Skip to content

Commit

Permalink
chore: merge loadValidateIBANNamespace() to loadValidateNamespace()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryubro committed Apr 2, 2024
1 parent 61f644c commit 74de31b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,80 @@ export async function loadValidateNamespace({ localize }) {
return import('@lion/ui/validate-messages-translations/en.js');
}
},
'lion-validate+iban': /** @param {string} locale */ locale => {
switch (locale) {
case 'bg-BG':
return import('@lion/ui/input-iban-translations/bg-BG.js');
case 'bg':
return import('@lion/ui/input-iban-translations/bg.js');
case 'cs-CZ':
return import('@lion/ui/input-iban-translations/cs-CZ.js');
case 'cs':
return import('@lion/ui/input-iban-translations/cs.js');
case 'de-DE':
return import('@lion/ui/input-iban-translations/de-DE.js');
case 'de':
return import('@lion/ui/input-iban-translations/de.js');
case 'en-AU':
return import('@lion/ui/input-iban-translations/en-AU.js');
case 'en-GB':
return import('@lion/ui/input-iban-translations/en-GB.js');
case 'en-US':
return import('@lion/ui/input-iban-translations/en-US.js');
case 'en-PH':
case 'en':
return import('@lion/ui/input-iban-translations/en.js');
case 'es-ES':
return import('@lion/ui/input-iban-translations/es-ES.js');
case 'es':
return import('@lion/ui/input-iban-translations/es.js');
case 'fr-FR':
return import('@lion/ui/input-iban-translations/fr-FR.js');
case 'fr-BE':
return import('@lion/ui/input-iban-translations/fr-BE.js');
case 'fr':
return import('@lion/ui/input-iban-translations/fr.js');
case 'hu-HU':
return import('@lion/ui/input-iban-translations/hu-HU.js');
case 'hu':
return import('@lion/ui/input-iban-translations/hu.js');
case 'it-IT':
return import('@lion/ui/input-iban-translations/it-IT.js');
case 'it':
return import('@lion/ui/input-iban-translations/it.js');
case 'nl-BE':
return import('@lion/ui/input-iban-translations/nl-BE.js');
case 'nl-NL':
return import('@lion/ui/input-iban-translations/nl-NL.js');
case 'nl':
return import('@lion/ui/input-iban-translations/nl.js');
case 'pl-PL':
return import('@lion/ui/input-iban-translations/pl-PL.js');
case 'pl':
return import('@lion/ui/input-iban-translations/pl.js');
case 'ro-RO':
return import('@lion/ui/input-iban-translations/ro-RO.js');
case 'ro':
return import('@lion/ui/input-iban-translations/ro.js');
case 'ru-RU':
return import('@lion/ui/input-iban-translations/ru-RU.js');
case 'ru':
return import('@lion/ui/input-iban-translations/ru.js');
case 'sk-SK':
return import('@lion/ui/input-iban-translations/sk-SK.js');
case 'sk':
return import('@lion/ui/input-iban-translations/sk.js');
case 'uk-UA':
return import('@lion/ui/input-iban-translations/uk-UA.js');
case 'uk':
return import('@lion/ui/input-iban-translations/uk.js');
case 'zh-CN':
case 'zh':
return import('@lion/ui/input-iban-translations/zh.js');
default:
return import('@lion/ui/input-iban-translations/en.js');
}
},
},
{ locale: localize.locale },
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Unparseable } from '@lion/ui/form-core.js';
import { IsIBAN, IsCountryIBAN, IsNotCountryIBAN } from '@lion/ui/input-iban.js';
import { loadValidateIBANNamespace } from '../loadValidateIBANNamespace.js';
import { loadValidateNamespace } from '../getLocalizedMessage.js';

let isLoaded = false;

Expand All @@ -19,18 +19,18 @@ export function loadInputIBANMessagesNoSideEffects({ localize }) {
/* @param {FeedbackMessageData} data */

IsIBAN.getMessage = async data => {
await loadValidateIBANNamespace({ localize });
await loadValidateNamespace({ localize });
return localize.msg('lion-validate+iban:error.IsIBAN', data);
};
IsCountryIBAN.getMessage = async data => {
await loadValidateIBANNamespace({ localize });
await loadValidateNamespace({ localize });
// If modelValue is Unparseable, the IsIBAN message is the more appropriate feedback
return data?.modelValue instanceof Unparseable
? localize.msg('lion-validate+iban:error.IsIBAN', data)
: localize.msg('lion-validate+iban:error.IsCountryIBAN', data);
};
IsNotCountryIBAN.getMessage = async data => {
await loadValidateIBANNamespace({ localize });
await loadValidateNamespace({ localize });
const _data = {
...data,
userSuppliedCountryCode:
Expand Down

0 comments on commit 74de31b

Please sign in to comment.