From b36501c974659564a940c1b13edf7b091e2bf20f Mon Sep 17 00:00:00 2001 From: Nikos Vasileiou Date: Wed, 3 Jul 2024 10:30:49 +0300 Subject: [PATCH] Expose params in missing policies --- packages/native/src/TxNative.js | 2 +- packages/native/src/index.d.ts | 6 +++--- packages/native/src/policies/PseudoTranslationPolicy.js | 2 +- packages/native/src/policies/SourceStringPolicy.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/native/src/TxNative.js b/packages/native/src/TxNative.js index e46c323d..11c62dae 100644 --- a/packages/native/src/TxNative.js +++ b/packages/native/src/TxNative.js @@ -151,7 +151,7 @@ export default class TxNative { } if (isMissing && locale) { - translation = this.missingPolicy.handle(translation, locale); + translation = this.missingPolicy.handle(translation, locale, params); } if (!isString(translation)) translation = `${translation}`; diff --git a/packages/native/src/index.d.ts b/packages/native/src/index.d.ts index 2c29513d..b23e34c4 100644 --- a/packages/native/src/index.d.ts +++ b/packages/native/src/index.d.ts @@ -46,7 +46,7 @@ declare module '@transifex/native' { } interface ITranslationPolicy { - handle(sourceString: string, localeCode: string): string; + handle(sourceString: string, localeCode: string, params: ITranslateParams): string; } interface IErrorPolicy { @@ -124,7 +124,7 @@ declare module '@transifex/native' { } export class PseudoTranslationPolicy implements ITranslationPolicy { - handle(sourceString: string, _localeCode: string): string; + handle(sourceString: string, _localeCode: string, _params: ITranslateParams): string; } export class SourceErrorPolicy implements IErrorPolicy { @@ -132,7 +132,7 @@ declare module '@transifex/native' { } export class SourceStringPolicy implements ITranslationPolicy { - handle(sourceString: string, _localeCode: string): string; + handle(sourceString: string, _localeCode: string, _params: ITranslateParams): string; } export class ThrowErrorPolicy implements IErrorPolicy { diff --git a/packages/native/src/policies/PseudoTranslationPolicy.js b/packages/native/src/policies/PseudoTranslationPolicy.js index 01e5e055..1ce6df51 100644 --- a/packages/native/src/policies/PseudoTranslationPolicy.js +++ b/packages/native/src/policies/PseudoTranslationPolicy.js @@ -62,7 +62,7 @@ const MAP = { * @class PseudoTranslationPolicy */ export default class PseudoTranslationPolicy { - handle(sourceString, localeCode) { + handle(sourceString, localeCode, params) { return sourceString .split(/__txnative__/) .map((group) => { diff --git a/packages/native/src/policies/SourceStringPolicy.js b/packages/native/src/policies/SourceStringPolicy.js index 0b0622d4..0c11550d 100644 --- a/packages/native/src/policies/SourceStringPolicy.js +++ b/packages/native/src/policies/SourceStringPolicy.js @@ -7,7 +7,7 @@ * @class SourceStringPolicy */ export default class SourceStringPolicy { - handle(sourceString, localeCode) { + handle(sourceString, localeCode, params) { return sourceString; } }