Skip to content
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/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"typecheck": "tsc --project tsconfig.json --pretty false --noEmit"
},
"dependencies": {
"@lunariajs/core": "https://pkg.pr.new/lunariajs/lunaria/@lunariajs/core@904b935",
"@lunariajs/core": "^0.2.0",
"vue-i18n-extract": "2.0.7"
},
"devDependencies": {
Expand Down
8 changes: 6 additions & 2 deletions packages/i18n/scripts/i18n-status.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Translation status reporter, inspired by npmx.dev's Lunaria build script (MIT license).
// The pinned @lunariajs/core build has no CLI, so the status is computed through its API.
// The status is computed through @lunariajs/core's API rather than its CLI.
import { mkdirSync, writeFileSync } from 'node:fs';

import { createLunaria } from '@lunariajs/core';

import { formatMissingKey } from './utils/lunaria-status.ts';

// `force: true` bypasses git caching so the status stays correct after rebases and merges.
const lunaria = await createLunaria({ force: true });
const status = await lunaria.getFullStatus();
Expand All @@ -27,7 +29,9 @@ const summaries = lunaria.config.locales.map((locale) => {
}

if ('missingKeys' in localization) {
missingKeys.push(...localization.missingKeys.map((key) => `${localization.path}: ${key}`));
missingKeys.push(
...localization.missingKeys.map((key) => formatMissingKey(localization.path, key)),
);
}
}

Expand Down
11 changes: 11 additions & 0 deletions packages/i18n/scripts/utils/lunaria-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Formatting for the translation status report written by `scripts/i18n-status.ts`.

/**
* One missing-key entry: the localization file, then the key as a dotted path.
*
* @lunariajs/core reports a missing key as its path segments (`['auth', 'signIn', 'title']`), so
* the segments are joined here rather than interpolated, which would comma-separate them.
*/
export function formatMissingKey(localizationPath: string, key: readonly string[]): string {
return `${localizationPath}: ${key.join('.')}`;
}
17 changes: 17 additions & 0 deletions packages/i18n/src/lunaria-status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest';

import { formatMissingKey } from '../scripts/utils/lunaria-status.js';

describe('formatMissingKey', () => {
it('joins the key path segments with dots after the localization path', () => {
expect(formatMissingKey('locales/it/auth.json', ['auth', 'signIn', 'title'])).toBe(
'locales/it/auth.json: auth.signIn.title',
);
});

it('renders a top-level key without a separator', () => {
expect(formatMissingKey('locales/it/common.json', ['appName'])).toBe(
'locales/it/common.json: appName',
);
});
});
70 changes: 50 additions & 20 deletions pnpm-lock.yaml

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

Loading