@yassidev/nuxt-directus 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1849,8 +1849,7 @@ function setupI18n(config, nuxt, logger) {
|
|
|
1849
1849
|
i18nPrefix: config.i18n.prefix
|
|
1850
1850
|
};
|
|
1851
1851
|
const path = "directus/locales";
|
|
1852
|
-
const
|
|
1853
|
-
codes.map((code) => {
|
|
1852
|
+
const result = codes.map((code) => {
|
|
1854
1853
|
const { dst } = addTemplate({
|
|
1855
1854
|
write: true,
|
|
1856
1855
|
filename: join(path, `${code}.json`),
|
|
@@ -1858,14 +1857,19 @@ function setupI18n(config, nuxt, logger) {
|
|
|
1858
1857
|
return JSON.stringify(Object.fromEntries(translations.map((translation) => [translation.key, translation.value])), null, 2);
|
|
1859
1858
|
})
|
|
1860
1859
|
});
|
|
1860
|
+
return { code, dst };
|
|
1861
|
+
});
|
|
1862
|
+
if (nuxt.options.dev && !nuxt.options._prepare) {
|
|
1863
|
+
const watcher = chokidar.watch(resolve(nuxt.options.buildDir, path, "*.json"), { ignoreInitial: true });
|
|
1861
1864
|
watcher.on("change", async (filePath) => {
|
|
1862
|
-
|
|
1865
|
+
const code = result.find((i) => i.dst === filePath)?.code;
|
|
1866
|
+
if (!code) return;
|
|
1863
1867
|
const translations = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
1864
1868
|
const done = await syncTranslations(code, translations, runtimeConfig);
|
|
1865
1869
|
if (!done) return;
|
|
1866
1870
|
logger.info(`Synced translations for locale: ${code}`);
|
|
1867
1871
|
});
|
|
1868
|
-
}
|
|
1872
|
+
}
|
|
1869
1873
|
}
|
|
1870
1874
|
nuxt.hook("i18n:registerModule", (register) => {
|
|
1871
1875
|
const locales = codes.map((code) => ({
|