@akinon/next 1.41.0-rc.0 → 1.41.0-rc.1
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/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@ import settings from 'settings';
|
|
|
2
2
|
import { LayoutProps, PageProps, RootLayoutProps } from '../../types';
|
|
3
3
|
import { redirect } from 'next/navigation';
|
|
4
4
|
import { ServerVariables } from '../../utils/server-variables';
|
|
5
|
-
import {
|
|
5
|
+
import { getCachedTranslations } from '../../utils/server-translation';
|
|
6
6
|
import { ROUTES } from 'routes';
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
|
|
@@ -50,7 +50,7 @@ const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
|
50
50
|
return redirect(ROUTES.HOME);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const translations = await
|
|
53
|
+
const translations = await getCachedTranslations(params.locale);
|
|
54
54
|
componentProps.translations = translations;
|
|
55
55
|
|
|
56
56
|
const locale = settings.localization.locales.find(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.41.0-rc.
|
|
4
|
+
"version": "1.41.0-rc.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
36
36
|
"@typescript-eslint/parser": "6.7.4",
|
|
37
37
|
"eslint": "^8.14.0",
|
|
38
|
-
"@akinon/eslint-plugin-projectzero": "1.41.0-rc.
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.41.0-rc.1",
|
|
39
39
|
"eslint-config-prettier": "8.5.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -5,10 +5,10 @@ import { getTranslateFn } from '../utils';
|
|
|
5
5
|
import { Translations } from '../types';
|
|
6
6
|
import settings from 'settings';
|
|
7
7
|
import logger from './log';
|
|
8
|
+
import { unstable_cache } from 'next/cache';
|
|
8
9
|
|
|
9
10
|
export const translations: Translations = {};
|
|
10
11
|
|
|
11
|
-
// TODO: Read translations from cache
|
|
12
12
|
export async function getTranslations(locale_: string) {
|
|
13
13
|
try {
|
|
14
14
|
const locale = settings.localization.locales.find(
|
|
@@ -52,6 +52,10 @@ export async function getTranslations(locale_: string) {
|
|
|
52
52
|
return translations;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export const getCachedTranslations = unstable_cache(async (locale: string) =>
|
|
56
|
+
getTranslations(locale)
|
|
57
|
+
);
|
|
58
|
+
|
|
55
59
|
export function t(path: string) {
|
|
56
60
|
return getTranslateFn(path, translations);
|
|
57
61
|
}
|