@@ -225,11 +225,10 @@ That being said, `next-intl` is agnostic to how you store messages and allows yo
225
225
``` tsx filename="i18n/request.ts"
226
226
import {getRequestConfig } from ' next-intl/server' ;
227
227
228
- export default getRequestConfig (async ({locale }) => {
229
- // ...
230
-
228
+ export default getRequestConfig (async () => {
231
229
return {
232
230
messages: (await import (` ../../messages/${locale }.json ` )).default
231
+ // ...
233
232
};
234
233
});
235
234
```
@@ -329,14 +328,14 @@ Specifying a time zone affects the rendering of dates and times. By default, the
329
328
``` tsx filename="i18n/request.ts"
330
329
import {getRequestConfig } from ' next-intl/server' ;
331
330
332
- export default getRequestConfig (async ({locale }) => {
333
- // ...
334
-
331
+ export default getRequestConfig (async () => {
335
332
return {
336
333
// The time zone can either be statically defined, read from the
337
334
// user profile if you store such a setting, or based on dynamic
338
335
// request information like the locale or a cookie.
339
336
timeZone: ' Europe/Vienna'
337
+
338
+ // ...
340
339
};
341
340
});
342
341
```
@@ -387,15 +386,15 @@ If you prefer to override the default, you can provide an explicit value for `no
387
386
```tsx filename="i18n/request.ts"
388
387
import { getRequestConfig } from 'next-intl/server';
389
388
390
- export default getRequestConfig(async ({ locale } ) => {
391
- // ...
392
-
389
+ export default getRequestConfig(async () => {
393
390
return {
394
391
// This is the default, a single date instance will be
395
392
// used by all Server Components to ensure consistency.
396
393
// Tip: This value can be mocked to a constant value
397
394
// for consistent results in end-to-end-tests.
398
395
now: new Date ()
396
+
397
+ // ...
399
398
};
400
399
} );
401
400
```
@@ -439,9 +438,7 @@ To achieve consistent date, time, number and list formatting, you can define a s
439
438
```tsx filename="i18n/request.ts"
440
439
import { getRequestConfig } from 'next-intl/server';
441
440
442
- export default getRequestConfig(async ({ locale } ) => {
443
- // ...
444
-
441
+ export default getRequestConfig(async () => {
445
442
return {
446
443
formats: {
447
444
dateTime: {
@@ -463,6 +460,8 @@ export default getRequestConfig(async ({locale}) => {
463
460
}
464
461
}
465
462
}
463
+
464
+ // ...
466
465
};
467
466
} );
468
467
```
@@ -552,14 +551,14 @@ To achieve consistent usage of translation values and reduce redundancy, you can
552
551
```tsx filename="i18n/request.tsx"
553
552
import { getRequestConfig } from 'next-intl/server';
554
553
555
- export default getRequestConfig(async ({ locale } ) => {
556
- // ...
557
-
554
+ export default getRequestConfig(async () => {
558
555
return {
559
556
defaultTranslationValues: {
560
557
important : (chunks ) => <b >{ chunks } </b >,
561
558
value: 123
562
559
}
560
+
561
+ // ...
563
562
};
564
563
} );
565
564
```
@@ -598,9 +597,7 @@ This behavior can be customized with the `onError` and `getMessageFallback` conf
598
597
import { getRequestConfig } from 'next-intl/server';
599
598
import { IntlErrorCode } from 'next-intl';
600
599
601
- export default getRequestConfig(async ({ locale } ) => {
602
- // ...
603
-
600
+ export default getRequestConfig(async () => {
604
601
return {
605
602
onError(error ) {
606
603
if (error .code === IntlErrorCode .MISSING_MESSAGE ) {
@@ -611,6 +608,7 @@ export default getRequestConfig(async ({locale}) => {
611
608
reportToErrorTracking (error );
612
609
}
613
610
},
611
+
614
612
getMessageFallback({namespace , key , error }) {
615
613
const path = [namespace , key ].filter ((part ) => part != null ).join (' .' );
616
614
@@ -620,6 +618,8 @@ export default getRequestConfig(async ({locale}) => {
620
618
return ' Dear developer, please fix this message: ' + path ;
621
619
}
622
620
}
621
+
622
+ // ...
623
623
};
624
624
} );
625
625
```
0 commit comments