Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: import translations for ml #14128

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions public/content/translations/ml/nft/index.md

Large diffs are not rendered by default.

133 changes: 120 additions & 13 deletions src/intl/ml/page-dapps.json

Large diffs are not rendered by default.

36 changes: 24 additions & 12 deletions src/intl/ml/page-eth.json

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions src/intl/ml/page-gas.json

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions src/intl/ml/page-learn.json

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions src/intl/ml/page-stablecoins.json

Large diffs are not rendered by default.

113 changes: 106 additions & 7 deletions src/intl/ml/page-what-is-ethereum.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/intl/ml/template-usecase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"template-usecase-dropdown-defi": "വികേന്ദ്രീകൃത ധനകാര്യം (DeFi)",
"template-usecase-dropdown-nft": "നോൺ-ഫഞ്ചിബിൾ ടോക്കണുകൾ (NFTs)",
"template-usecase-dropdown-dao": "വികേന്ദ്രീകൃത സ്വയംഭരണ സ്ഥാപനങ്ങൾ (DAOs)",
"template-usecase-dropdown-social-networks": "വികേന്ദ്രീകൃത സോഷ്യൽ നെറ്റ്‌വർക്കുകൾ",
"template-usecase-dropdown-identity": "വികേന്ദ്രീകൃത വ്യക്തിവിവരം",
"template-usecase-dropdown-desci": "വികേന്ദ്രീകൃത ധനകാര്യം (DeFi)",
"template-usecase-dropdown-refi": "റീജനറേറ്റീവ് ഫിനാൻസ് (ReFi)",
"template-usecase-dropdown": "Ethereum ഉപയോഗ കേസുകൾ",
"template-usecase-banner": "Ethereum ൻ്റെ ഉപയോഗങ്ങൾ എല്ലായ്പ്പോഴും വികസിക്കുകയും വികസിക്കുകയും ചെയ്യുന്നു. കാര്യങ്ങൾ കൂടുതൽ വ്യക്തമോ കാലികമോ ആക്കുമെന്ന് നിങ്ങൾ കരുതുന്ന ഏത് വിവരവും ചേർക്കുക.",
"template-usecase-edit-link": "പേജ് എഡിറ്റുചെയ്യുക",
"template-usecase-dropdown-aria": "കേസ് ഡ്രോപ്പ്ഡൗൺ മെനു ഉപയോഗിക്കുക"
}
6 changes: 1 addition & 5 deletions src/scripts/crowdin/translations/getTranslations.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fs from "fs"

import { checkMarkdown } from "../../markdownChecker"
import crowdin from "../api-client/crowdinClient"
import crowdinImport from "../import/main"
import type { BucketsList } from "../import/types"

import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH, SUMMARY_PATH } from "./constants"
import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH } from "./constants"
import getApprovedBuckets from "./getApprovedBuckets"
import { decompressFile, downloadFile } from "./utils"

Expand Down Expand Up @@ -43,9 +42,6 @@ async function main() {

// Run Crowdin import script with buckets from Notion
crowdinImport(buckets)

// Check markdown
checkMarkdown(SUMMARY_PATH)
} catch (error: unknown) {
console.error((error as Error).message)
}
Expand Down
53 changes: 17 additions & 36 deletions src/scripts/crowdin/translations/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execSync } from "child_process"
import fs, { readFileSync, unlinkSync, writeFileSync } from "fs"
import fs, { unlinkSync, writeFileSync } from "fs"
import path from "path"
import { Readable } from "stream"
import { finished } from "stream/promises"
Expand All @@ -9,9 +9,6 @@ import decompress from "decompress"

import { INTL_JSON_DIR, TRANSLATIONS_DIR } from "../../../lib/constants"

import { SUMMARY_PATH } from "./constants"
import { QASummary } from "./types"

export const downloadFile = async (url: string, writePath: string) => {
// Get directory from writePath and ensure it exists
const dir = writePath.substring(0, writePath.lastIndexOf("/"))
Expand Down Expand Up @@ -40,33 +37,6 @@ export const decompressFile = async (filePath: string, targetDir: string) => {
console.log("✅ Decompression complete.")
}

const getQAMessage = (locale: string) => {
console.log("Checking summary path:", SUMMARY_PATH)
if (!fs.existsSync(SUMMARY_PATH)) {
console.error("Could not find summary path:", SUMMARY_PATH)
throw new Error("No summary file found.")
}

const summaryJson: QASummary = JSON.parse(readFileSync(SUMMARY_PATH, "utf-8"))
const qaResults = summaryJson[locale]
? summaryJson[locale].map((s) => "- " + s).join("\n")
: null

if (!qaResults) return "No QA issues found"
return `
\`\`\`shell
yarn markdown-checker
\`\`\`

<details><summary>Unfold for ${summaryJson[locale].length} result(s)</summary>

${qaResults}
</details>

@coderabbitai review
`
}

export const createLocaleTranslationPR = (
locale: string,
buckets: number[]
Expand All @@ -88,8 +58,22 @@ export const createLocaleTranslationPR = (
}).trim()
execSync(`git checkout -b ${branchName}`)
execSync("git reset .")
execSync(`git add ${TRANSLATIONS_DIR}/${locale}`)
execSync(`git add ${INTL_JSON_DIR}/${locale}`)

// Check if the translations directory exists and contains files
const translationsDir = path.join(TRANSLATIONS_DIR, locale)
if (
fs.existsSync(translationsDir) &&
fs.readdirSync(translationsDir).length > 0
) {
execSync(`git add ${translationsDir}`)
}

// Check if the intl JSON directory exists and contains files
const intlJsonDir = path.join(INTL_JSON_DIR, locale)
if (fs.existsSync(intlJsonDir) && fs.readdirSync(intlJsonDir).length > 0) {
execSync(`git add ${intlJsonDir}`)
}

execSync(`git commit -m "${message}"`)
execSync(`git push origin ${branchName}`)

Expand All @@ -101,9 +85,6 @@ export const createLocaleTranslationPR = (

## Content buckets imported
${buckets.sort((a, b) => a - b).join(", ")}

## Markdown QA checker alerts
${getQAMessage(locale)}
`

const bodyWritePath = path.resolve(process.cwd(), "body.txt")
Expand Down