Skip to content
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

TXNative: Expose params in missing policies #225

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/native/src/TxNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
6 changes: 3 additions & 3 deletions packages/native/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -124,15 +124,15 @@ 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 {
handle(_error: Error, sourceString: string, _localeCode: string, _params: ITranslateParams): string;
}

export class SourceStringPolicy implements ITranslationPolicy {
handle(sourceString: string, _localeCode: string): string;
handle(sourceString: string, _localeCode: string, _params: ITranslateParams): string;
}

export class ThrowErrorPolicy implements IErrorPolicy {
Expand Down
2 changes: 1 addition & 1 deletion packages/native/src/policies/PseudoTranslationPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/native/src/policies/SourceStringPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @class SourceStringPolicy
*/
export default class SourceStringPolicy {
handle(sourceString, localeCode) {
handle(sourceString, localeCode, params) {
return sourceString;
}
}
Loading