22 lines
660 B
TypeScript
22 lines
660 B
TypeScript
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { definePlugin } from "@wrnexus/plugin";
|
|
|
|
export interface I18nPluginOptions {
|
|
components?: boolean;
|
|
componentDir?: string;
|
|
}
|
|
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
export function i18nComponentsDir(): string {
|
|
return join(packageRoot, "components");
|
|
}
|
|
export function i18nPlugin(options: I18nPluginOptions = {}) {
|
|
return definePlugin({
|
|
name: "@wrnexus/i18n",
|
|
version: "0.8.0",
|
|
componentDirs:
|
|
options.components === false ? [] : [options.componentDir ?? i18nComponentsDir()],
|
|
});
|
|
}
|
|
export default i18nPlugin;
|