Skip to content

Commit 41ce38f

Browse files
committed
feat: add internationalization support for API server description in OpenAPI component
1 parent 267ff41 commit 41ce38f

File tree

12 files changed

+54
-32
lines changed

12 files changed

+54
-32
lines changed

client/src/components/openapi.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import { useEffect, useState } from "react";
33
import SwaggerUI from "swagger-ui-react";
44
import "swagger-ui-react/swagger-ui.css";
5+
import { useTranslation } from "react-i18next";
56

67
export function OpenAPI() {
8+
const { t } = useTranslation();
79
const url = import.meta.env.BASE_URL.endsWith("/")
810
? import.meta.env.BASE_URL + "openapi.json"
911
: import.meta.env.BASE_URL + "/openapi.json";
@@ -20,7 +22,7 @@ export function OpenAPI() {
2022
url: import.meta.env.API_BASE_URL.endsWith("/api")
2123
? import.meta.env.API_BASE_URL.split("/api")[0]
2224
: import.meta.env.API_BASE_URL,
23-
description: "API server",
25+
description: t("api-server"),
2426
},
2527
];
2628
setOpenApiSpec(data);

client/src/locales/base/ar-SA.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"error-adding-oauth-id": "خطأ في إضافة معرف OAuth",
150150
"oauth-id-added-successfully": "أضاف معرف Oauth بنجاح",
151151
"oauth-id-format-hint": "تلميح تنسيق معرف OAUTH",
152-
"please-enter-valid-oauth-id": "الرجاء إدخال معرف Oauth صالح"
152+
"please-enter-valid-oauth-id": "الرجاء إدخال معرف Oauth صالح",
153+
"api-server": "خادم API"
153154
}

client/src/locales/base/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"oauth-id-added-successfully": "OAuth Id added successfully",
150150
"error-adding-oauth-id": "Error adding OAuth Id",
151151
"add-oauth-id-to": "Add OAuth Id",
152-
"oauth-id-format-hint": "Oauth Id Format Hint"
152+
"oauth-id-format-hint": "Oauth Id Format Hint",
153+
"api-server": "API server"
153154
}

client/src/locales/base/es-ES.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"error-adding-oauth-id": "Error agregar OAuth ID",
150150
"oauth-id-added-successfully": "OAUTH ID agregado con éxito",
151151
"oauth-id-format-hint": "Formato de identificación de OAuth Sugerencia",
152-
"please-enter-valid-oauth-id": "Ingrese una ID de OAuth válida"
152+
"please-enter-valid-oauth-id": "Ingrese una ID de OAuth válida",
153+
"api-server": "Servidor API"
153154
}

client/src/locales/base/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"error-adding-oauth-id": "Erreur ajoutant ID OAuth",
150150
"oauth-id-added-successfully": "OAuth ID a ajouté avec succès",
151151
"oauth-id-format-hint": "Indice de format d'identification OAuth",
152-
"please-enter-valid-oauth-id": "Veuillez saisir un identifiant OAuth valide"
152+
"please-enter-valid-oauth-id": "Veuillez saisir un identifiant OAuth valide",
153+
"api-server": "Serveur API"
153154
}

client/src/locales/base/he-IL.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"error-adding-oauth-id": "שגיאה הוספת מזהה OAuth",
150150
"oauth-id-added-successfully": "מזהה Oauth הוסיף בהצלחה",
151151
"oauth-id-format-hint": "רמז לתבנית זיהוי של Oauth",
152-
"please-enter-valid-oauth-id": "אנא הזן מזהה OAuth תקף"
152+
"please-enter-valid-oauth-id": "אנא הזן מזהה OAuth תקף",
153+
"api-server": "שרת API"
153154
}

client/src/locales/base/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@
149149
"error-adding-oauth-id": "错误添加OAuth ID",
150150
"oauth-id-added-successfully": "Oauth ID成功添加了",
151151
"oauth-id-format-hint": "OAuth ID格式提示",
152-
"please-enter-valid-oauth-id": "请输入有效的OAuth ID"
152+
"please-enter-valid-oauth-id": "请输入有效的OAuth ID",
153+
"api-server": "API服务器"
153154
}

cloudflare-worker/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"lint": "eslint --fix",
1313
"start": "wrangler dev",
1414
"test": "set -a && source ../.env && set +a && node --experimental-vm-modules ./node_modules/.bin/jest",
15+
"d1:create": "npx wrangler d1 execute --local --file src/db/create.sql feedbackflow-db",
1516
"d1:init": "npx wrangler d1 execute --local --file src/test/seed-test-data.sql feedbackflow-db",
1617
"cf-typegen": "wrangler types"
1718
},

cloudflare-worker/src/db/create.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
PRAGMA foreign_keys = ON;
2727

2828
-- Suppression des tables si elles existent déjà (pour réinitialisation)
29-
-- DROP TABLE IF EXISTS refunds;
30-
-- DROP TABLE IF EXISTS publications;
31-
-- DROP TABLE IF EXISTS feedbacks;
32-
-- DROP TABLE IF EXISTS purchases;
33-
-- DROP TABLE IF EXISTS id_mappings;
34-
-- DROP TABLE IF EXISTS testers;
29+
DROP TABLE IF EXISTS refunds;
30+
DROP TABLE IF EXISTS publications;
31+
DROP TABLE IF EXISTS feedbacks;
32+
DROP TABLE IF EXISTS purchases;
33+
DROP TABLE IF EXISTS id_mappings;
34+
DROP TABLE IF EXISTS testers;
3535

3636
-- Table des testeurs
3737
CREATE TABLE testers (
@@ -125,6 +125,7 @@ BEGIN
125125
END;
126126

127127
-- Vue pour obtenir facilement les achats avec leur statut de feedback, publication et remboursement
128+
DROP VIEW IF EXISTS purchase_status;
128129
CREATE VIEW purchase_status AS
129130
SELECT
130131
p.id,
@@ -134,6 +135,8 @@ SELECT
134135
p.description,
135136
p.amount,
136137
p.refunded,
138+
pub.screenshot as publication_screenshot,
139+
p.screenshot as purchase_screenshot,
137140
CASE WHEN f.id IS NOT NULL THEN 1 ELSE 0 END as has_feedback,
138141
CASE WHEN pub.id IS NOT NULL THEN 1 ELSE 0 END as has_publication,
139142
CASE WHEN r.id IS NOT NULL THEN 1 ELSE 0 END as has_refund
@@ -144,6 +147,7 @@ FROM
144147
LEFT JOIN refunds r ON p.id = r.purchase_id;
145148

146149
-- Vue pour obtenir des statistiques par testeur
150+
DROP VIEW IF EXISTS tester_statistics;
147151
CREATE VIEW tester_statistics AS
148152
SELECT
149153
t.uuid,

cloudflare-worker/src/db/d1-db.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,18 +598,23 @@ export class CloudflareD1DB implements FeedbackFlowDB {
598598

599599
const { results } = await preparedStatement.all();
600600

601-
return results.map((row) => ({
602-
purchase: row.id as string,
603-
testerUuid: row.tester_uuid as string,
604-
date: row.date as string,
605-
order: row.order_number as string,
606-
description: row.description as string,
607-
amount: row.amount as number,
608-
refunded: Boolean(row.refunded),
609-
hasFeedback: Boolean(row.has_feedback),
610-
hasPublication: Boolean(row.has_publication),
611-
hasRefund: Boolean(row.has_refund),
612-
}));
601+
return results.map(
602+
(row) =>
603+
({
604+
purchase: row.id as string,
605+
testerUuid: row.tester_uuid as string,
606+
date: row.date as string,
607+
order: row.order_number as string,
608+
description: row.description as string,
609+
amount: row.amount as number,
610+
refunded: Boolean(row.refunded),
611+
hasFeedback: Boolean(row.has_feedback),
612+
hasPublication: Boolean(row.has_publication),
613+
hasRefund: Boolean(row.has_refund),
614+
publicationScreenshot: row.publication_screenshot as string,
615+
purchaseScreenshot: row.purchase_screenshot as string,
616+
}) as PurchaseStatus,
617+
);
613618
},
614619
};
615620

0 commit comments

Comments
 (0)