@zachhandley/ez-i18n 0.4.1 → 0.4.12
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/index.js +15 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -667,6 +667,19 @@ export function tc(key, params) {
|
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
});
|
|
670
|
+
server.watcher.on("change", (file) => {
|
|
671
|
+
if (!file.endsWith(".json")) return;
|
|
672
|
+
for (const info of translationInfo.values()) {
|
|
673
|
+
if (info.files.includes(file)) {
|
|
674
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_PREFIX + VIRTUAL_TRANSLATIONS);
|
|
675
|
+
if (mod) {
|
|
676
|
+
server.moduleGraph.invalidateModule(mod);
|
|
677
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
678
|
+
}
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
});
|
|
670
683
|
}
|
|
671
684
|
};
|
|
672
685
|
}
|
|
@@ -947,6 +960,7 @@ async function __loadPublicJson(url, absolutePath) {
|
|
|
947
960
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
948
961
|
const response = await fetch(url);
|
|
949
962
|
if (!response.ok) {
|
|
963
|
+
if (response.status === 404) return {};
|
|
950
964
|
throw new Error(\`Failed to fetch translations from \${url}: \${response.status}\`);
|
|
951
965
|
}
|
|
952
966
|
return __parseJsonResponse(response);
|
|
@@ -957,6 +971,7 @@ async function __loadPublicJson(url, absolutePath) {
|
|
|
957
971
|
if (assets && typeof assets.fetch === 'function') {
|
|
958
972
|
const response = await assets.fetch(new URL(url, 'https://assets.local'));
|
|
959
973
|
if (!response.ok) {
|
|
974
|
+
if (response.status === 404) return {};
|
|
960
975
|
throw new Error(\`Failed to fetch translations from \${url}: \${response.status}\`);
|
|
961
976
|
}
|
|
962
977
|
return __parseJsonResponse(response);
|