@korioinc/next-core 1.0.4 → 1.0.5
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.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Messages } from '@lingui/core';
|
|
2
|
+
/**
|
|
3
|
+
* Load lingui catalogs and initialize the i18n setup
|
|
4
|
+
* This function should be called by the app at startup
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // In your app's initialization (e.g., next.config.ts or app layout)
|
|
9
|
+
* import { loadLinguiCatalogs } from '@korioinc/next-core/i18n/lingui.loader';
|
|
10
|
+
*
|
|
11
|
+
* // Load all catalogs
|
|
12
|
+
* await loadLinguiCatalogs(async (locale) => {
|
|
13
|
+
* const { messages } = await import(`./lang/${locale}.po`);
|
|
14
|
+
* return messages;
|
|
15
|
+
* }, ['en', 'ko', 'pseudo']);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadLinguiCatalogs(loader: (locale: string) => Promise<Messages>, locales: string[]): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Alternative: Load catalogs with a static import map
|
|
21
|
+
* This is useful when you know all locales at build time
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import enMessages from './lang/en.po';
|
|
26
|
+
* import koMessages from './lang/ko.po';
|
|
27
|
+
*
|
|
28
|
+
* loadLinguiCatalogsStatic({
|
|
29
|
+
* en: enMessages.messages,
|
|
30
|
+
* ko: koMessages.messages,
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadLinguiCatalogsStatic(messages: {
|
|
35
|
+
[locale: string]: Messages;
|
|
36
|
+
}): void;
|
|
37
|
+
//# sourceMappingURL=lingui.loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lingui.loader.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,EAC7C,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GAAG,IAAI,CAEvF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { setAllMessages } from './lingui.setup';
|
|
2
|
+
/**
|
|
3
|
+
* Load lingui catalogs and initialize the i18n setup
|
|
4
|
+
* This function should be called by the app at startup
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // In your app's initialization (e.g., next.config.ts or app layout)
|
|
9
|
+
* import { loadLinguiCatalogs } from '@korioinc/next-core/i18n/lingui.loader';
|
|
10
|
+
*
|
|
11
|
+
* // Load all catalogs
|
|
12
|
+
* await loadLinguiCatalogs(async (locale) => {
|
|
13
|
+
* const { messages } = await import(`./lang/${locale}.po`);
|
|
14
|
+
* return messages;
|
|
15
|
+
* }, ['en', 'ko', 'pseudo']);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export async function loadLinguiCatalogs(loader, locales) {
|
|
19
|
+
const allMessages = {};
|
|
20
|
+
for (const locale of locales) {
|
|
21
|
+
try {
|
|
22
|
+
const messages = await loader(locale);
|
|
23
|
+
allMessages[locale] = messages;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(`Failed to load messages for locale "${locale}":`, error);
|
|
27
|
+
// Continue loading other locales
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
setAllMessages(allMessages);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Alternative: Load catalogs with a static import map
|
|
34
|
+
* This is useful when you know all locales at build time
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import enMessages from './lang/en.po';
|
|
39
|
+
* import koMessages from './lang/ko.po';
|
|
40
|
+
*
|
|
41
|
+
* loadLinguiCatalogsStatic({
|
|
42
|
+
* en: enMessages.messages,
|
|
43
|
+
* ko: koMessages.messages,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function loadLinguiCatalogsStatic(messages) {
|
|
48
|
+
setAllMessages(messages);
|
|
49
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lingui.setup.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lingui.setup.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAI/C,OAAO,aAAa,CAAC;AAIrB,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAS/B,KAAK,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAGnD,eAAO,MAAM,WAAW,EAAE,eAKzB,CAAC;AAEF,KAAK,gBAAgB,GAAG;KAAG,CAAC,IAAI,gBAAgB,GAAG,IAAI;CAAE,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,gBAQL,CAAC;AAE3B,eAAO,MAAM,eAAe,GAAI,QAAQ,gBAAgB,KAAG,IAM1D,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { setupI18n } from '@lingui/core';
|
|
2
2
|
import linguiConfig from 'lingui.config';
|
|
3
|
+
import { loadCatalog as loadCatalogFromApp } from 'lingui.locales';
|
|
3
4
|
import 'server-only';
|
|
4
5
|
const { locales } = linguiConfig;
|
|
5
6
|
async function loadCatalog(locale) {
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
[locale]: messages,
|
|
9
|
-
};
|
|
7
|
+
return loadCatalogFromApp(locale);
|
|
10
8
|
}
|
|
11
9
|
const catalogs = await Promise.all(locales.map(loadCatalog));
|
|
12
10
|
// transform array of catalogs into a single object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korioinc/next-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./ads": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"pretendard": "^1.3.9",
|
|
95
95
|
"tailwind-merge": "^3.3.1",
|
|
96
96
|
"valtio": "^2.0.0",
|
|
97
|
-
"@korioinc/next-conf": "1.0.
|
|
97
|
+
"@korioinc/next-conf": "1.0.3"
|
|
98
98
|
},
|
|
99
99
|
"publishConfig": {
|
|
100
100
|
"access": "public",
|