Skip to content

Commit

Permalink
🐛 fix(build): fix lingui build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed May 7, 2024
1 parent 4cc926d commit 7bf3bbe
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 54 deletions.
20 changes: 20 additions & 0 deletions lingui.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const locales = [
"en-us", // english
"zh-cn", // chinese (simplified)
"zh-tw", // chinese (traditional)
"fr-fr", // french
"es-es", // spanish
"de-de", // german
"it-it", // italian
"ru-ru", // russian
"ja-jp", // japanese
"pt-br", // portuguese
"ko-kr", // korean
];

/** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
locales,
sourceLocale: "en-us",
pseudoLocale: "pseudo",
};
37 changes: 3 additions & 34 deletions lingui.config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
const { formatter } = require("@lingui/format-po");

const locales = [
"en-us", // english
"zh-cn", // chinese (simplified)
"zh-tw", // chinese (traditional)
"fr-fr", // french
"es-es", // spanish
"de-de", // german
"it-it", // italian
"ru-ru", // russian
"ja-jp", // japanese
"pt-br", // portuguese
"ko-kr", // korean

// "bn-in", // bengali
// "ar-sa", // arabic
// "pl-pl", // polish
// "tr-tr", // turkish
// "vi-vn", // vietnamese
// "id-id", // indonesian
// "uk-ua", // ukrainian
// "hu-hu", // hungarian
// "ro-ro", // romanian
// "sv-se", // swedish
// "nl-nl", // dutch
// "fa-ir", // persian
// "cs-cz", // czech
// "el-gr", // greek
// "th-th", // thai
// "he-il", // hebrew
];
const linguiConfigBase = require("./lingui.config.base");

if (process.env.NODE_ENV !== "production") {
locales.push("pseudo");
linguiConfigBase.locales.push("pseudo");
}

/** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
locales,
sourceLocale: "en-us",
pseudoLocale: "pseudo",
...linguiConfigBase,
catalogs: [
{
path: "<rootDir>/src/translations/locales/{locale}",
Expand Down
12 changes: 12 additions & 0 deletions next.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const linguiConfig = require("./lingui.config");

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
i18n: {
locales: linguiConfig.locales,
defaultLocale: linguiConfig.sourceLocale,
},
};

module.exports = nextConfig;
7 changes: 2 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});

const linguiConfig = require("./lingui.config");
const nextConfigBase = require("./next.config.base");

/** @type {import('next').NextConfig} */
const nextConfig = {
...nextConfigBase,
reactStrictMode: true,
experimental: {
swcPlugins: [["@lingui/swc-plugin", {}]],
},
i18n: {
locales: linguiConfig.locales,
defaultLocale: linguiConfig.sourceLocale,
},
webpack: (config) => {
config.module.rules.push({
test: /\.po$/,
Expand Down
1 change: 0 additions & 1 deletion release.sh

This file was deleted.

21 changes: 21 additions & 0 deletions src/backend/entities/entities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ export class EntitiesApiService {
return primaryField;
}

// TODO
// async getEntityPrimaryField(entity: string): Promise<string> {
// const primaryField = (await this.getEntityFields(entity)).filter(
// ({ isId }) => isId
// );

// if (primaryField.length === 0) {
// throw new BadRequestError(
// "This entity doesn't have a primary key. Kindly ask your administrator to add one then restart the application and this error will go away."
// );
// }

// if (primaryField.length > 1) {
// throw new BadRequestError(
// "This entity has multiple primary keys. Kindly ask your administrator to fix this issue by ensuring only ONE primary key exists then restart the application and this error will go away."
// );
// }

// return primaryField[0].name;
// }

async getEntityFromSchema(entity: string): Promise<IDBSchema> {
return (await this.getDBSchemaModels())[entity];
}
Expand Down
24 changes: 14 additions & 10 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ const replaceRandomCharaters = (envContent: string) => {

copyEnvHere();

process.stdout.write("\n");

const endpoint = `http://localhost:${process.env.PORT || 3000}`;

console.log(`
Expand All @@ -104,6 +102,8 @@ const replaceRandomCharaters = (envContent: string) => {
`🚀 Application started successfully at ${terminalLink(endpoint, endpoint)}`
);

process.stdout.write("\n");

const WAIT_FOR_NEXT_TO_START = 1000;

/*
Expand All @@ -116,23 +116,27 @@ const replaceRandomCharaters = (envContent: string) => {
fetch(`${endpoint}/api/healthcheck`).catch(() => {});
}, WAIT_FOR_NEXT_TO_START);

let stdSkip = true;
let stdCount = 0;
const STD_SKIP_COUNT = 3;

stdout.on("data", (chunk) => {
const data = (chunk || "").toString();

if (data.startsWith("info")) {
if (stdSkip) {
stdCount += 1;

if (stdCount > STD_SKIP_COUNT) {
stdSkip = false;
}

return;
}

process.stdout.write(data);
});

stderr.on("data", (chunk) => {
const data = (chunk || "").toString();
if (data.startsWith("warn")) {
return;
}
process.stderr.write(data);
});
stderr.pipe(process.stderr);
})().catch((err) => {
console.error(err);
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/views/entity/Crud/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export function EntityCrudSettings() {
return (
<BaseEntitySettingsLayout>
{entityFields.data.length > 1 &&
// TODO
entityFields.data.findIndex((field) => field.isId) === -1 && (
<>
<WarningAlert message="This entity doesn't have a primary key. Kindly add one to this entity and restart the application so as not to run into errors when managing its data" />
Expand Down
4 changes: 0 additions & 4 deletions src/translations/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import { I18nProvider } from "@lingui/react";
import languages from "./languages";

async function loadCatalog(locale: string) {
if (process.env.NODE_ENV === "production") {
const { messages } = await import(`./locales/${locale}`);
return messages;
}
const { messages } = await import(`./locales/${locale}.po`);

return messages;
Expand Down

0 comments on commit 7bf3bbe

Please sign in to comment.