next-i18next
Version:
The easiest way to translate your NextJs apps.
30 lines (29 loc) • 1.21 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
//#region src/pagesRouter/utils.ts
const getFallbackForLng = (lng, fallbackLng) => {
if (typeof fallbackLng === "string") return [fallbackLng];
if (Array.isArray(fallbackLng)) return fallbackLng;
if (typeof fallbackLng === "object") {
const fallbackList = fallbackLng[lng];
const fallbackDefault = fallbackLng.default;
return [...fallbackList ?? [], ...fallbackDefault ?? []];
}
if (typeof fallbackLng === "function") return getFallbackForLng(lng, fallbackLng(lng));
return [];
};
const unique = (list) => Array.from(new Set(list));
/**
* This hook behaves like `useLayoutEffect` on the client,
* and `useEffect` on the server(no effect).
*
* Since using `useLayoutEffect` on the server cause warning messages in nextjs,
* this hook is workaround for that.
*/
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
//#endregion
exports.getFallbackForLng = getFallbackForLng;
exports.unique = unique;
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
//# sourceMappingURL=utils.cjs.map