2024-03-02 16:55:28 +00:00
|
|
|
import { writeFileSync } from "fs";
|
2024-06-29 10:54:04 +00:00
|
|
|
import { PayloadSDK } from "src/shared/payload/payload-sdk";
|
2024-03-02 16:55:28 +00:00
|
|
|
|
|
|
|
const TRANSLATION_FOLDER = `${process.cwd()}/src/i18n`;
|
|
|
|
|
2024-06-29 10:54:04 +00:00
|
|
|
const payload = new PayloadSDK(
|
|
|
|
import.meta.env.PAYLOAD_API_URL,
|
|
|
|
import.meta.env.PAYLOAD_USER,
|
|
|
|
import.meta.env.PAYLOAD_PASSWORD
|
|
|
|
);
|
|
|
|
|
2024-03-02 16:55:28 +00:00
|
|
|
try {
|
2024-06-29 10:54:04 +00:00
|
|
|
const { data: wordings } = await payload.getWordings();
|
2024-03-02 16:55:28 +00:00
|
|
|
const keys = wordings.map(({ name }) => name);
|
|
|
|
|
|
|
|
let result = "";
|
|
|
|
result += "export type WordingKey =\n";
|
|
|
|
result += ` | "` + keys.join(`"\n | "`) + `";\n`;
|
|
|
|
|
|
|
|
writeFileSync(`${TRANSLATION_FOLDER}/wordings-keys.ts`, result, {
|
|
|
|
encoding: "utf-8",
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Failed to get the sdk", e);
|
|
|
|
}
|