This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"image": "node:20", | ||
"shutdownAction": "stopContainer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
### Requirements: | ||
*Please follow the below requirements for the PR* | ||
|
||
* Not generated using an online translator. | ||
* Updates only a single language. | ||
* Added account to [`contributors.json`](https://github.com/KatsuteDev/Background-Localization/blob/main/contributors.json). | ||
* Strings contain correct amount of placeholders `{#}`. | ||
|
||
### Changes: | ||
*List the translations that were updated* | ||
|
||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const r1 = Object.keys(JSON.parse(fs.readFileSync(path.join(__dirname, "en", "readme.json"), "utf-8"))); | ||
const t1 = Object.keys(JSON.parse(fs.readFileSync(path.join(__dirname, "en", "translations.json"), "utf-8"))); | ||
const readme = JSON.parse(fs.readFileSync(path.join(__dirname, "en", "readme.json"), "utf-8")); | ||
const translations = JSON.parse(fs.readFileSync(path.join(__dirname, "en", "translations.json"), "utf-8")); | ||
|
||
let error = false; | ||
|
||
const wildcard = (str) => ((str ?? "").match(/{[a-zA-Z0-9]+}/g) ?? []).length; | ||
|
||
for(const folder of fs.readdirSync(__dirname).filter(f => !f.includes('.') && f !== "en")){ | ||
const r2 = Object.keys(JSON.parse(fs.readFileSync(path.join(__dirname, folder, "readme.json"), "utf-8"))); | ||
/* readme */ { | ||
const obj = JSON.parse(fs.readFileSync(path.join(__dirname, folder, "readme.json"), "utf-8")); | ||
|
||
for(const key of Object.keys(readme)){ | ||
if(!Object.keys(obj).includes(key)){ | ||
console.error(`[${folder}] Missing README translation for '${key}'`); | ||
error = true; | ||
continue; | ||
} | ||
|
||
const [wcO, wcT] = [wildcard(obj[key]), wildcard(readme[key])]; | ||
|
||
for(const key of r1){ | ||
if(!r2.includes(key)){ | ||
console.error(`[${folder}] Missing README translation for '${key}'`); | ||
error = true; | ||
if(wcO !== wcT){ | ||
console.error(`[${folder}] '${key}' has incorrect amount of placeholders (${wcO} ≠ ${wcT})`); | ||
error = true; | ||
continue; | ||
} | ||
} | ||
} | ||
|
||
const t2 = Object.keys(JSON.parse(fs.readFileSync(path.join(__dirname, folder, "translations.json"), "utf-8"))); | ||
/* translations */ { | ||
const obj = JSON.parse(fs.readFileSync(path.join(__dirname, folder, "translations.json"), "utf-8")); | ||
|
||
for(const key of Object.keys(translations)){ | ||
if(!Object.keys(obj).includes(key)){ | ||
console.error(`[${folder}] Missing translation for '${key}'`); | ||
error = true; | ||
continue; | ||
} | ||
|
||
const [wcO, wcT] = [wildcard(obj[key]), wildcard(translations[key])]; | ||
|
||
for(const key of t1){ | ||
if(!t2.includes(key)){ | ||
console.error(`[${folder}] Missing package translation for '${key}'`); | ||
error = true; | ||
if(wcO !== wcT){ | ||
console.error(`[${folder}] '${key}' has incorrect amount of placeholders (${wcO} ≠ ${wcT})`); | ||
error = true; | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if(error){ | ||
process.exit(1); | ||
} | ||
error && process.exit(1); |