cloudflare-next-intl 0.2.1 → 0.2.2
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.
|
@@ -4,6 +4,7 @@ import { localeCookieName } from "../../config/cookie_key";
|
|
|
4
4
|
import { getLocaleCache, getMessageCache, setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables";
|
|
5
5
|
import { cache } from "react";
|
|
6
6
|
import { localesSet } from "../../config/middleware";
|
|
7
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
7
8
|
/**
|
|
8
9
|
* Loads and caches messages for a specific locale using dynamic import.
|
|
9
10
|
* Prevents redundant file loads and handles import errors gracefully.
|
|
@@ -11,7 +12,10 @@ import { localesSet } from "../../config/middleware";
|
|
|
11
12
|
* @returns A promise that resolves to the TranslationObject for the given locale.
|
|
12
13
|
*/
|
|
13
14
|
async function iGetMessage(locale) {
|
|
14
|
-
|
|
15
|
+
// In dev, always re-import so editing a messages/*.json file takes effect
|
|
16
|
+
// on the next request without a full server restart. loadedTranslations
|
|
17
|
+
// is a module-level cache that otherwise persists for the whole process.
|
|
18
|
+
const message = isDev ? undefined : getMessageCache(locale);
|
|
15
19
|
if (message) {
|
|
16
20
|
return message;
|
|
17
21
|
}
|