diff --git a/packages/localizer/index.ts b/packages/localizer/index.ts index 05816e1..a226f43 100644 --- a/packages/localizer/index.ts +++ b/packages/localizer/index.ts @@ -35,13 +35,14 @@ class ShrimpleLocalizer implements Init { private async readLocalizationDirectory() { const translationFiles = []; const localPath = resolve('assets', 'locals'); + console.log(localPath) assert(existsSync(localPath), "No directory \"assets/locals\" found for the localizer") for(const json_path of await fs.readdir(localPath)) { const parsed = JSON.parse(await fs.readFile(join(localPath, json_path), 'utf8')) const name = json_path.substring(0, json_path.lastIndexOf('.')); translationFiles.push({ [name]: parsed }) } - return translationFiles.reduce((acc, cur ) => ({ ...cur, ...acc }), {}); + return translationFiles.reduce((acc, cur) => ({ ...cur, ...acc }), {}); } } @@ -57,18 +58,6 @@ export const local = (i: string, local: string) => { return Service('localizer').translate(i, local) } -/** - * Returns a record of locales to their respective translations. - * Note: this method only works AFTER your container has been initiated - * @example - * ```ts - * assert.deepEqual(localsFor("salute.hello"), { "en-US": "hello", "es": "hola" }) - * ``` - */ -export const localsFor = (path: string) => { - return Service('localizer').translationsFor(path) -} - /** * An init plugin to add localization fields to a command module. @@ -109,7 +98,7 @@ export const localize = (root?: string) => * @example * ```ts * await makeDependencies(({ add }) => { - * add('@sern/localizer', Localization()); + * add('localizer', Localization()); * }); * ``` **/ diff --git a/packages/localizer/package.json b/packages/localizer/package.json index 7812f81..c78b19f 100644 --- a/packages/localizer/package.json +++ b/packages/localizer/package.json @@ -5,6 +5,7 @@ "main": "dist/index.js", "scripts": { "build": "tsc", + "watch": "tsc --watch", "test": "vitest" }, "dependencies": {