Skip to content

Commit

Permalink
Merge pull request #25 from FNLB-Project/dev
Browse files Browse the repository at this point in the history
merge dev into stable
  • Loading branch information
tnfAngel authored Jun 27, 2024
2 parents 4c2eb91 + 8d44e27 commit b89db50
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"cSpell.words": ["biomejs", "bunx", "fnlb", "FNLB"]
"cSpell.words": ["biomejs", "bunx", "fnlb", "FNLB", "Patatas"]
}
Binary file modified bun.lockb
Binary file not shown.
30 changes: 30 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Generated by dts-bundle-generator v8.1.2

export declare enum Locales {
Default = "en",
De = "de",
Es = "es",
Fr = "fr",
It = "it",
Pl = "pl",
Pt = "pt",
Tr = "tr"
}
export type LocalesString = `${Locales}`;
export declare class LocaleClient {
localeObject: Record<string, string>;
localeString: LocalesString;
defaultLocaleString: LocalesString;
removeDash: boolean;
constructor({ locale, localeRoute, localeModule, removeDash }: {
locale?: LocalesString;
localeRoute: string;
localeModule: string;
removeDash?: boolean;
});
translate(key: string, variables?: Record<string, string>): string;
numberToLocaleString(number: number): string;
static transformToSupportedLocale(locale: any): LocalesString;
}

export {};
1 change: 1 addition & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@fnlb-project/locales",
"description": "FNLB Translation Service",
"version": "1.1.0",
"main": "src/index.ts",
"types": "src/index.ts",
"version": "1.1.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "bun run build.ts",
Expand All @@ -25,4 +25,4 @@
"typescript": "^5.3.3"
},
"packageManager": "pnpm@8.14.1"
}
}
10 changes: 7 additions & 3 deletions src/classes/LocaleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ export class LocaleClient {
this.localeString = this.removeDash
? ((locale || this.defaultLocaleString).split(
'-'
)[0] as LocalesString)
)[0] as LocalesString)
: locale || this.defaultLocaleString;

let requiredLocale;

try {
requiredLocale = require(`../locales/${localeRoute}/${locale}.json`);
requiredLocale = require(
`../src/locales/${localeRoute}/${locale}.json`
);
} catch {
requiredLocale = require(`../locales/${localeRoute}/${this.defaultLocaleString}.json`);
requiredLocale = require(
`../src/locales/${localeRoute}/${this.defaultLocaleString}.json`
);

this.localeString = this.defaultLocaleString;
}
Expand Down

0 comments on commit b89db50

Please sign in to comment.