chore(input-tel): localize data
This commit is contained in:
parent
b6073fe4ba
commit
2c7bcd5f80
4 changed files with 84 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-expect-error ref, createRef are exported (?)
|
||||
import { render, html, css, ref, createRef } from '@lion/core';
|
||||
import { LionInputTel } from '@lion/input-tel';
|
||||
import { localize } from '@lion/localize';
|
||||
|
||||
/**
|
||||
* Note: one could consider to implement LionInputTelDropdown as a
|
||||
|
|
@ -96,8 +97,7 @@ export class LionInputTelDropdown extends LionInputTel {
|
|||
'model-value-changed': this._onDropdownValueChange,
|
||||
},
|
||||
labels: {
|
||||
// TODO: localize this
|
||||
selectCountry: 'Select country',
|
||||
selectCountry: localize.msg('lion-input-tel:selectCountry'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@
|
|||
"./define": "./define.js",
|
||||
"./test-suites": "./test-suites/index.js",
|
||||
"./test-helpers": "./test-helpers/index.js",
|
||||
"./translations/*": "./translations/*",
|
||||
"./docs/*": "./docs/*"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { liveFormatPhoneNumber } from './preprocessors.js';
|
|||
import { formatPhoneNumber } from './formatters.js';
|
||||
import { parsePhoneNumber } from './parsers.js';
|
||||
import { PhoneNumber } from './validators.js';
|
||||
import { localizeNamespaceLoader } from './localizeNamespaceLoader.js';
|
||||
|
||||
/**
|
||||
* @typedef {import('../types').FormatStrategy} FormatStrategy
|
||||
|
|
@ -26,9 +27,13 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
|
|||
activeRegion: { type: String },
|
||||
_phoneUtil: { type: Object, state: true },
|
||||
_needsLightDomRender: { type: Number, state: true },
|
||||
_derivedRegionCode: { type: String, state: true },
|
||||
};
|
||||
|
||||
static localizeNamespaces = [
|
||||
{ 'lion-input-tel': localizeNamespaceLoader },
|
||||
...super.localizeNamespaces,
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently active region based on:
|
||||
* 1. allowed regions: get the region from configured allowed regions (if one entry)
|
||||
|
|
|
|||
75
packages/input-tel/src/localizeNamespaceLoader.js
Normal file
75
packages/input-tel/src/localizeNamespaceLoader.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
export const localizeNamespaceLoader = /** @param {string} locale */ locale => {
|
||||
switch (locale) {
|
||||
case 'bg-BG':
|
||||
return import('@lion/input-tel/translations/bg-BG.js');
|
||||
case 'bg':
|
||||
return import('@lion/input-tel/translations/bg.js');
|
||||
case 'cs-CZ':
|
||||
return import('@lion/input-tel/translations/cs-CZ.js');
|
||||
case 'cs':
|
||||
return import('@lion/input-tel/translations/cs.js');
|
||||
case 'de-DE':
|
||||
return import('@lion/input-tel/translations/de-DE.js');
|
||||
case 'de':
|
||||
return import('@lion/input-tel/translations/de.js');
|
||||
case 'en-AU':
|
||||
return import('@lion/input-tel/translations/en-AU.js');
|
||||
case 'en-GB':
|
||||
return import('@lion/input-tel/translations/en-GB.js');
|
||||
case 'en-US':
|
||||
return import('@lion/input-tel/translations/en-US.js');
|
||||
case 'en-PH':
|
||||
case 'en':
|
||||
return import('@lion/input-tel/translations/en.js');
|
||||
case 'es-ES':
|
||||
return import('@lion/input-tel/translations/es-ES.js');
|
||||
case 'es':
|
||||
return import('@lion/input-tel/translations/es.js');
|
||||
case 'fr-FR':
|
||||
return import('@lion/input-tel/translations/fr-FR.js');
|
||||
case 'fr-BE':
|
||||
return import('@lion/input-tel/translations/fr-BE.js');
|
||||
case 'fr':
|
||||
return import('@lion/input-tel/translations/fr.js');
|
||||
case 'hu-HU':
|
||||
return import('@lion/input-tel/translations/hu-HU.js');
|
||||
case 'hu':
|
||||
return import('@lion/input-tel/translations/hu.js');
|
||||
case 'it-IT':
|
||||
return import('@lion/input-tel/translations/it-IT.js');
|
||||
case 'it':
|
||||
return import('@lion/input-tel/translations/it.js');
|
||||
case 'nl-BE':
|
||||
return import('@lion/input-tel/translations/nl-BE.js');
|
||||
case 'nl-NL':
|
||||
return import('@lion/input-tel/translations/nl-NL.js');
|
||||
case 'nl':
|
||||
return import('@lion/input-tel/translations/nl.js');
|
||||
case 'pl-PL':
|
||||
return import('@lion/input-tel/translations/pl-PL.js');
|
||||
case 'pl':
|
||||
return import('@lion/input-tel/translations/pl.js');
|
||||
case 'ro-RO':
|
||||
return import('@lion/input-tel/translations/ro-RO.js');
|
||||
case 'ro':
|
||||
return import('@lion/input-tel/translations/ro.js');
|
||||
case 'ru-RU':
|
||||
return import('@lion/input-tel/translations/ru-RU.js');
|
||||
case 'ru':
|
||||
return import('@lion/input-tel/translations/ru.js');
|
||||
case 'sk-SK':
|
||||
return import('@lion/input-tel/translations/sk-SK.js');
|
||||
case 'sk':
|
||||
return import('@lion/input-tel/translations/sk.js');
|
||||
case 'uk-UA':
|
||||
return import('@lion/input-tel/translations/uk-UA.js');
|
||||
case 'uk':
|
||||
return import('@lion/input-tel/translations/uk.js');
|
||||
case 'zh-CN':
|
||||
case 'zh':
|
||||
return import('@lion/input-tel/translations/zh.js');
|
||||
default:
|
||||
return import('@lion/input-tel/translations/en.js');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue