fix(i18n): complete command center texts and merge client fallbacks
This commit is contained in:
1 parent
8b59bd1d2d
commit
b12e405b34
5 files changed
+272
-5
No files matched your search
+12
-3
@@ -1,5 +1,6 @@
|
||||
import { cookies, headers } from "next/headers";
|
||||
import { getRequestConfig } from "next-intl/server";
|
||||
import { mergeMessages } from "./merge-messages";
|
||||
|
||||
// i18n WITHOUT routing: the locale is chosen by a `NEXT_LOCALE` cookie, then
|
||||
// the Accept-Language header, and finally English as fallback.
|
||||
@@ -83,11 +84,19 @@ export default getRequestConfig(async () => {
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages,
|
||||
messages: mergeMessages(fallback, messages),
|
||||
// Never throw on a missing message — use the English value, or a humanised
|
||||
// key as a last resort.
|
||||
getMessageFallback({ key }: { key: string }) {
|
||||
const fromEnglish = key
|
||||
getMessageFallback({
|
||||
namespace,
|
||||
key,
|
||||
}: {
|
||||
namespace?: string;
|
||||
key: string;
|
||||
}) {
|
||||
const fromEnglish = [namespace, key]
|
||||
.filter(Boolean)
|
||||
.join(".")
|
||||
.split(".")
|
||||
.reduce<unknown>(
|
||||
(o, k) =>
|
||||
|
||||
Reference in new issue
Block a user