mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 17:25:21 +00:00
Changed .localize method to need mandatory translations to be passed as second parameter
This commit is contained in:
@@ -669,8 +669,8 @@ export default class PKPass extends Bundle {
|
||||
// ************************** //
|
||||
|
||||
/**
|
||||
* Allows to specify a language to be added to the
|
||||
* final bundle, along with some optionals translations.
|
||||
* Allows to add a localization details to the
|
||||
* final bundle with some translations.
|
||||
*
|
||||
* If the language already exists, translations will be
|
||||
* merged with the existing ones.
|
||||
@@ -685,11 +685,11 @@ export default class PKPass extends Bundle {
|
||||
|
||||
public localize(
|
||||
lang: string,
|
||||
translations?: { [key: string]: string } | null,
|
||||
translations: { [key: string]: string } | null,
|
||||
) {
|
||||
if (typeof lang !== "string") {
|
||||
throw new TypeError(
|
||||
formatMessage(Messages.LANGUAGES.INVALID_TYPE, typeof lang),
|
||||
formatMessage(Messages.LANGUAGES.INVALID_LANG, typeof lang),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -698,6 +698,13 @@ export default class PKPass extends Bundle {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!translations || !Object.keys(translations).length) {
|
||||
console.warn(
|
||||
formatMessage(Messages.LANGUAGES.NO_TRANSLATIONS, lang),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this[localizationSymbol][lang] ??= {};
|
||||
|
||||
if (typeof translations === "object" && !Array.isArray(translations)) {
|
||||
|
||||
Reference in New Issue
Block a user