Skip to content

Commit

Permalink
fix: localization types
Browse files Browse the repository at this point in the history
  • Loading branch information
RozmarinUS committed Jun 2, 2024
1 parent f3fb44c commit 87563fb
Show file tree
Hide file tree
Showing 5 changed files with 3,775 additions and 2,891 deletions.
Empty file modified .devcontainer/post-create.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"url": "https://github.com/GlobalartInc/nestcord"
},
"dependencies": {
"@globalart/text-utils": "^1.0.1",
"@globalart/text-utils": "^1.0.2",
"@nestjs/axios": "^3.0.2",
"@nestjs/schedule": "^4.0.2",
"axios": "^1.7.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replacePlaceholdersInString } from '@globalart/text-utils';
import { replacePlaceholdersInObjectWithFlatten } from '@globalart/text-utils';
import { BaseLocalizationAdapter } from './base-localization.adapter';
import { LocalizationInterceptor } from '../interceptors';

Expand All @@ -8,13 +8,13 @@ interface DefaultLocalizationAdapterOptions {
}

export class DefaultLocalizationAdapter extends BaseLocalizationAdapter<DefaultLocalizationAdapterOptions> {
public getTranslation(key: string, locale: string, placeholders?: Record<string, string>): string {
public getTranslation(key: string, locale: string, placeholders?: unknown): string {
const translation = this.getTranslations(locale)[key] || this.getFallbackTranslation(key);

return placeholders ? replacePlaceholdersInString(translation, placeholders) : translation;
return placeholders ? replacePlaceholdersInObjectWithFlatten(translation, placeholders) : translation;
}

public translate(key: string, placeholders?: Record<string, string>): string {
public translate(key: string, placeholders?: unknown): string {
const currentTranslationFn = LocalizationInterceptor.getCurrentTranslationFn();

return currentTranslationFn
Expand Down
4 changes: 2 additions & 2 deletions packages/localization/adapters/nested-localization.adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replacePlaceholdersInString } from '@globalart/text-utils';
import { replacePlaceholdersInObjectWithFlatten } from '@globalart/text-utils';
import { BaseLocalizationAdapter } from './base-localization.adapter';
import { LocalizationInterceptor } from '../interceptors';

Expand All @@ -16,7 +16,7 @@ export class NestedLocalizationAdapter extends BaseLocalizationAdapter<NestedLoc
const translations = this.getTranslations(locale);
const translation = this.findTranslation(translations, key) || this.getFallbackTranslation(key);

return replacePlaceholdersInString(translation, placeholders);
return replacePlaceholdersInObjectWithFlatten(translation, placeholders);
}

public translate(key: string, placeholders?: Record<string, string>): string {
Expand Down
Loading

0 comments on commit 87563fb

Please sign in to comment.