Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Feb 14, 2025
1 parent 439b0b9 commit e453bab
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 31 deletions.
3 changes: 1 addition & 2 deletions demos/client-bundle-example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export default defineConfig(({ command, mode }) => {
loadEnv();
return {
watch: false,
mode: "production",
base: "./",
mode: "development",
server: {
host: true,
cors: true,
Expand Down
3 changes: 1 addition & 2 deletions demos/provider-mock/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ async function startApi() {

apiApp.use(cors());
apiApp.use(express.json());
// @ts-ignore
apiApp.use(i18nMiddleware({}));
apiApp.use(await i18nMiddleware({}));
apiApp.use(prosopoRouter());
apiApp.use(handleErrors);

Expand Down
1 change: 0 additions & 1 deletion packages/api-express-router/src/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const handleErrors = (
response: Response,
next: NextFunction,
) => {
// @ts-ignore
const { code, statusMessage, jsonError } = unwrapError(err, request.i18n);
response.statusMessage = statusMessage;
response.set("content-type", "application/json");
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ async function main() {

//if main process
if (isMain(import.meta.url, "provider")) {
loadI18next(true).then((i18n) => {
console.log("\ni18next.language", i18n.language, "\n");
// @ts-ignore
console.log("\ni18next.id", i18n.id, "\n");
loadI18next(true).then(() => {
main()
.then(() => {
log.info("Running main process...");
Expand Down
17 changes: 1 addition & 16 deletions packages/common/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,7 @@ type ApiContextParams = BaseContextParams & {
i18n?: { t: TFunction<"translation", undefined> };
};

// let i18next: i18n;
//
// async function loadi18nextLocal() {
// i18next = await loadI18next();
// // @ts-ignore
// i18next.id = "error";
// }
//
// // Immediately call the function (synchronously starts, but it’s async)
// console.log("i18next being loaded from error.ts");
// loadi18nextLocal();

// if i18n is not loaded then we use this
const backupTranslationObj = { t: (key: string) => key };

export abstract class ProsopoBaseError<
Expand All @@ -73,17 +62,13 @@ export abstract class ProsopoBaseError<
if (error instanceof Error) {
super(error.message);
this.translationKey = options?.translationKey;

console.log("\ntranslating error 1", options?.translationKey, "\n");

this.context = {
...(options?.context as ContextType),
...(options?.translationKey
? { translationMessage: i18n.t(options.translationKey) }
: {}),
};
} else {
console.log("\ntranslating error 2", error, "\n");
super(i18n.t(error));
this.translationKey = error;
this.context = options?.context;
Expand Down
4 changes: 1 addition & 3 deletions packages/locale/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# i18next browser localization for Prosopo in various frameworks

- React
# i18next localization for Prosopo
1 change: 0 additions & 1 deletion packages/locale/src/i18nFrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const reactOptions: InitOptions = {
};

const getLoadPath = (language: string, namespace: string) => {
console.log(import.meta);
const filename = import.meta.url.split("/").pop();
return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
};
Expand Down
1 change: 1 addition & 0 deletions packages/locale/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export { default as i18nMiddleware } from "./i18nMiddleware.js";
export { default as loadI18next } from "./loadI18next.js";
export { Languages, LanguageSchema } from "./translations.js";
Expand Down
1 change: 1 addition & 0 deletions packages/locale/src/translationKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { z } from "zod";
import translationEn from "./locales/en/translation.json" assert {
type: "json",
Expand Down
1 change: 0 additions & 1 deletion packages/procaptcha-bundle/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ for (const packageName of packages) {
// Add the tsconfig for each package to tsConfigPaths
tsConfigPaths.push(path.resolve(`../${packageName}/tsconfig.json`));
}
console.log(`${workspaceRoot}/packages/locale/src/locales/.*.json`);

const copyDir = {
srcDir: `${workspaceRoot}/packages/locale/src/locales`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const ProcaptchaWidget = (props: ProcaptchaProps) => {

useEffect(() => {
if (config.language) {
console.log("Language changed");
loadI18next(false).then((i18n) => {
i18n.changeLanguage(config.language).then((r) => r);
});
Expand Down
1 change: 1 addition & 0 deletions packages/provider/src/express.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import type { TFunction } from "i18next";

declare module "express-serve-static-core" {
Expand Down

0 comments on commit e453bab

Please sign in to comment.