Skip to content

Commit

Permalink
feat: update azure-translator-code to version 1.1.18 and add Klingon …
Browse files Browse the repository at this point in the history
…language support

fix: incorrect translation for multi lingual text.
  • Loading branch information
gabriel-logan committed Nov 1, 2024
1 parent c4ab72c commit 1317ec7
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@vercel/analytics": "^1.3.1",
"ace-builds": "^1.34.2",
"axios": "^1.7.7",
"azure-translator-code": "^1.1.17",
"azure-translator-code": "^1.1.18",
"next": "14.2.3",
"next-international": "^1.2.4",
"react": "^18",
Expand Down
9 changes: 7 additions & 2 deletions docs/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { translate, translateText } from "azure-translator-code";

import localesCodes from "@/lib/localesCode";
import { getScopedI18n } from "@/locales/server";

const key = process.env.AZURE_API_KEY ?? "";
Expand Down Expand Up @@ -92,7 +91,13 @@ export async function makeTranslationMultilang(
}

const fromLang = formData.get("fromLang") as string;
const toLangs = localesCodes.filter((code) => formData.get(code) === "on");
const toLangs: string[] = [];

formData.forEach((value, key) => {
if (value === "on" && key !== "fromLang" && key !== "toTranslate") {
toLangs.push(key);
}
});

if (!toLangs.length) {
return {
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/FormTransLiveText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function FormTransLiveText({ locale }: Readonly<Locale>) {
{ id: "el", name: scopedT("Langs.Greek") },
{ id: "id", name: scopedT("Langs.Indonesian") },
{ id: "ms", name: scopedT("Langs.Malay") },
{ id: "tlh-Latn", name: scopedT("Langs.Klingon") },
];
return (
<form
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/FormTransMultiText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function FormTransMultiText({ locale }: Readonly<Locale>) {
{ id: "el", name: scopedT("Langs.Greek") },
{ id: "id", name: scopedT("Langs.Indonesian") },
{ id: "ms", name: scopedT("Langs.Malay") },
{ id: "tlh-Latn", name: scopedT("Langs.Klingon") },
];

return (
Expand Down
2 changes: 2 additions & 0 deletions docs/src/components/FormTransUnicJson/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function FormTransUnicJson() {
<option value="el">{scopedT("Langs.Greek")}</option>
<option value="id">{scopedT("Langs.Indonesian")}</option>
<option value="ms">{scopedT("Langs.Malay")}</option>
<option value="tlh-Latn">{scopedT("Langs.Klingon")}</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -114,6 +115,7 @@ export default function FormTransUnicJson() {
<option value="el">{scopedT("Langs.Greek")}</option>
<option value="id">{scopedT("Langs.Indonesian")}</option>
<option value="ms">{scopedT("Langs.Malay")}</option>
<option value="tlh-Latn">{scopedT("Langs.Klingon")}</option>
</select>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion docs/src/locales/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"Thai": "Thai",
"Turkish": "Turkish",
"Vietnamese": "Vietnamese",
"Malay": "Malay"
"Malay": "Malay",
"Klingon": "Klingon"
},
"Paste the json code here": "Paste the json code here",
"Len": "Len",
Expand Down
3 changes: 2 additions & 1 deletion docs/src/locales/pt/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"Thai": "Tailandês",
"Turkish": "Turco",
"Vietnamese": "Vietnamita",
"Malay": "Malaio"
"Malay": "Malaio",
"Klingon": "Klingon"
},
"Paste the json code here": "Cole o código json aqui",
"Len": "Caract",
Expand Down
3 changes: 2 additions & 1 deletion docs/src/types/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export type LanguagesCode =
| "hu"
| "el"
| "id"
| "ms";
| "ms"
| "tlh-Latn";
10 changes: 5 additions & 5 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1109,13 +1109,13 @@ __metadata:
languageName: node
linkType: hard

"azure-translator-code@npm:^1.1.17":
version: 1.1.17
resolution: "azure-translator-code@npm:1.1.17"
"azure-translator-code@npm:^1.1.18":
version: 1.1.18
resolution: "azure-translator-code@npm:1.1.18"
dependencies:
axios: "npm:^1.7.7"
uuid: "npm:^10.0.0"
checksum: 10c0/231036038b9109f506f2ef45ae937965cc71992a27c483373e8801522de082ba2e526fdc821792f09868cd92e79dfd52de1d9f24b89d5d022ba0f27dbd15b372
checksum: 10c0/f12a1b9b84ef9c1cc5648266a2c218d572a3b058552713c04f3b1e2a632e6f33c86f4108a98ddc73f37d64ec8c91f937ce22d5c5484e760a3c3feafa6a498cd3
languageName: node
linkType: hard

Expand All @@ -1131,7 +1131,7 @@ __metadata:
"@vercel/analytics": "npm:^1.3.1"
ace-builds: "npm:^1.34.2"
axios: "npm:^1.7.7"
azure-translator-code: "npm:^1.1.17"
azure-translator-code: "npm:^1.1.18"
eslint: "npm:^8.57.0"
eslint-config-next: "npm:14.2.3"
eslint-config-universe: "npm:^12.1.0"
Expand Down

0 comments on commit 1317ec7

Please sign in to comment.