Skip to content

Commit

Permalink
add translations (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
habbas33 authored Dec 26, 2023
1 parent 6e48acd commit 3b9b467
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 119 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
pull_request:
branches: [main]
jobs:
test_keys:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run a simple diff check
uses: actions/setup-node@v3
with:
node-version: 18
- name: Diff Keys
run: node main.js
test_keys:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run a simple diff check
uses: actions/setup-node@v3
with:
node-version: 18
- name: Diff Keys
run: node main.js
4 changes: 2 additions & 2 deletions Contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ Steps to Contribute
- Not to send out changes to github
- We can send it via `git push`
- NOTE: If you get error like `fatal: The current branch YOUR_BRANCH_NAME has no upstream branch.`, don't panic just use the command mentioned below.
- Which should be something like `git push --set-upstream origin YOUR_BRANCH_NAME`
- Which should be something like `git push --set-upstream origin YOUR_BRANCH_NAME`
- If we have pushed successfully, we can view that branch in our github account in web browser
- Step 6: Creating a PR(Pull Request)
- This is the final step to make your contribution to be included in the translations.
- Creating a PR is simple, You navigate to your branch in the github repository page.
- Then Click `Contribute` and then `Open a pull request` to the `main` repository

You can also refer here to this article on [How to Contribute to Projects on Github](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)
You can also refer here to this article on [How to Contribute to Projects on Github](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Voyager Translations

## Simple How to translate

- Checkout to a new branch for your locale say `git checkout -b hi`
- Make a copy of folder `en` and rename it as new locale e.g `hi`
- Translate all or keys which are required in file `translation.json` which should be inside `YOUR_LOCALE/translation.json`
- Once done, commit you changes push to the branch and make a PR to `main` branch.


## Locales naming

- You can take help and name folder as country code [link](https://www.w3.org/International/O-charset-lang.html)
- In case country is present in above link, use respective country code from any other source.


## Current languages (Languages which are translated)

- English (en)
- French (fr)
- Korean (ko)
Expand Down
129 changes: 62 additions & 67 deletions add-key.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,80 @@
const fs = require("fs")

const ignoreFiles = [
".github",
".git",
"Contribution.md",
"LICENSE",
"main.js",
"add-key.js",
"README.md",
];
".github",
".git",
"Contribution.md",
"LICENSE",
"main.js",
"add-key.js",
"README.md",
]

function getFiles(dir, files = []) {
// Get an array of all files and directories in the passed directory using fs.readdirSync
const fileList = fs.readdirSync(dir);
// Get an array of all files and directories in the passed directory using fs.readdirSync
const fileList = fs.readdirSync(dir)

const filteredFileList = fileList.filter(
(file) => !ignoreFiles.includes(file)
);
const filteredFileList = fileList.filter(file => !ignoreFiles.includes(file))

for (const file of filteredFileList) {
const name = `${dir}/${file}`;
for (const file of filteredFileList) {
const name = `${dir}/${file}`

if (fs.statSync(name).isDirectory()) {
getFiles(name, files);
} else {
files.push(name);
}
if (fs.statSync(name).isDirectory()) {
getFiles(name, files)
} else {
files.push(name)
}
return files;
}
return files
}

function add_key() {
const args = process.argv.slice(2);

if (args.length % 2 !== 0) {
throw new Error("Even number or args required. Key+Value like")
const args = process.argv.slice(2)

if (args.length % 2 !== 0) {
throw new Error("Even number or args required. Key+Value like")
}

const pairs = []
for (let i = 0; i < args.length; i += 2) {
if (i + 1 < args.length) {
pairs.push([args[i], args[i + 1]])
} else {
pairs.push([args[i]])
}

const pairs = [];
for (let i = 0; i < args.length; i += 2) {
if (i + 1 < args.length) {
pairs.push([args[i], args[i + 1]]);
}

console.log("Command-line argument pairs:")
console.log(pairs)

const files = getFiles(".")

pairs.forEach(pair => {
const [new_key, new_value] = pair

files.forEach(file => {
try {
const data = fs.readFileSync(file, {
encoding: "utf-8",
})
const thisLang = JSON.parse(data)
const thisLangKeys = Object.keys(thisLang)
if (!thisLangKeys.includes(new_key)) {
console.info(`Wiriting locale ${file} | Adding ${new_key} ":" ${new_value}`)
// If this lang doesn't contain this key then only update
const newFileData = {
...thisLang,
[new_key]: new_value,
}
fs.writeFileSync(file, JSON.stringify(newFileData, null, 2))
} else {
pairs.push([args[i]]);
console.warn(`locale ${file} already has ${new_key}. Skipping`)
}
}

console.log("Command-line argument pairs:");
console.log(pairs);

const files = getFiles(".");

pairs.forEach((pair) => {
const [new_key, new_value] = pair;

files.forEach((file) => {
try {
const data = fs.readFileSync(file, {
encoding: "utf-8",
});
const thisLang = JSON.parse(data);
const thisLangKeys = Object.keys(thisLang);
if (!thisLangKeys.includes(new_key)) {
console.info(`Wiriting locale ${file} | Adding ${new_key} ":" ${new_value}`)
// If this lang doesn't contain this key then only update
const newFileData = {
...thisLang,
[new_key]: new_value
};
fs.writeFileSync(file, JSON.stringify(newFileData, null, 2))
} else {
console.warn(`locale ${file} already has ${new_key}. Skipping`)
}
} catch (e) {
console.error(`Unexpected Error: ${e}`);
}
});
} catch (e) {
console.error(`Unexpected Error: ${e}`)
}
})



})
}

add_key()
add_key()
22 changes: 21 additions & 1 deletion en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,25 @@
"sierra_bytecode": "Sierra Bytecode",
"starknet_remix": "Starknet Remix",
"starknet_cli_starkli": "Starknet CLI (Starkli)",
"number_of_owners": "Number of owners"
"number_of_owners": "Number of owners",
"daily_average_standardized_tps": "Daily Average Standardized Transactions Per Second (STPS)",
"daily_average_erc20_scaling": "Daily Average ERC20 Scaling",
"standardized_tps_today": "Standardized Transactions Per Second today",
"erc20_scaling_today": "ERC20 scaling today",
"user_operations": "User Operations",
"daily_average_uops": "Daily Average User Operations Per Second (UOPS)",
"daily_max_uops": "Daily Max User Operations Per Second",
"daily_average_uopb": "Daily Average User Operations Per Block (UOPB)",
"daily_average_acps": "Daily Average Account Calls Per Second (ACPS)",
"daily_max_acps": "Daily Max Account Calls Per Second",
"daily_average_acpb": "Daily Average Account Calls Per Block (ACPB)",
"number_upos_today": "Number of user operations per second today",
"max_recorded_uops_today": "Max recorded user operations per second today",
"number_uopb_today": "Number of user operations per block today",
"total_user_operations": "Total number of user operations today",
"number_acps_today": "Number of account calls per second today",
"max_recorded_acps_today": "Max recorded account calls per second today",
"number_acpb_today": "Number of account calls per block today",
"total_account_calls": "Total number of account calls today",
"relative_compute": "Relative Compute"
}
22 changes: 21 additions & 1 deletion es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,25 @@
"sierra_bytecode": "Sierra Bytecode",
"starknet_remix": "Starknet Remix",
"starknet_cli_starkli": "Starknet CLI (Starkli)",
"number_of_owners": "Number of owners"
"number_of_owners": "Number of owners",
"daily_average_standardized_tps": "Daily Average Standardized Transactions Per Second (STPS)",
"daily_average_erc20_scaling": "Daily Average ERC20 Scaling",
"standardized_tps_today": "Standardized Transactions Per Second today",
"erc20_scaling_today": "ERC20 scaling today",
"user_operations": "User Operations",
"daily_average_uops": "Daily Average User Operations Per Second (UOPS)",
"daily_max_uops": "Daily Max User Operations Per Second",
"daily_average_uopb": "Daily Average User Operations Per Block (UOPB)",
"daily_average_acps": "Daily Average Account Calls Per Second (ACPS)",
"daily_max_acps": "Daily Max Account Calls Per Second",
"daily_average_acpb": "Daily Average Account Calls Per Block (ACPB)",
"number_upos_today": "Number of user operations per second today",
"max_recorded_uops_today": "Max recorded user operations per second today",
"number_uopb_today": "Number of user operations per block today",
"total_user_operations": "Total number of user operations today",
"number_acps_today": "Number of account calls per second today",
"max_recorded_acps_today": "Max recorded account calls per second today",
"number_acpb_today": "Number of account calls per block today",
"total_account_calls": "Total number of account calls today",
"relative_compute": "Relative Compute"
}
22 changes: 21 additions & 1 deletion fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,25 @@
"sierra_bytecode": "Sierra Bytecode",
"starknet_remix": "Starknet Remix",
"starknet_cli_starkli": "Starknet CLI (Starkli)",
"number_of_owners": "Number of owners"
"number_of_owners": "Number of owners",
"daily_average_standardized_tps": "Daily Average Standardized Transactions Per Second (STPS)",
"daily_average_erc20_scaling": "Daily Average ERC20 Scaling",
"standardized_tps_today": "Standardized Transactions Per Second today",
"erc20_scaling_today": "ERC20 scaling today",
"user_operations": "User Operations",
"daily_average_uops": "Daily Average User Operations Per Second (UOPS)",
"daily_max_uops": "Daily Max User Operations Per Second",
"daily_average_uopb": "Daily Average User Operations Per Block (UOPB)",
"daily_average_acps": "Daily Average Account Calls Per Second (ACPS)",
"daily_max_acps": "Daily Max Account Calls Per Second",
"daily_average_acpb": "Daily Average Account Calls Per Block (ACPB)",
"number_upos_today": "Number of user operations per second today",
"max_recorded_uops_today": "Max recorded user operations per second today",
"number_uopb_today": "Number of user operations per block today",
"total_user_operations": "Total number of user operations today",
"number_acps_today": "Number of account calls per second today",
"max_recorded_acps_today": "Max recorded account calls per second today",
"number_acpb_today": "Number of account calls per block today",
"total_account_calls": "Total number of account calls today",
"relative_compute": "Relative Compute"
}
22 changes: 21 additions & 1 deletion ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,5 +594,25 @@
"sierra_bytecode": "Sierra Bytecode",
"starknet_remix": "Starknet Remix",
"starknet_cli_starkli": "Starknet CLI (Starkli)",
"number_of_owners": "Number of owners"
"number_of_owners": "Number of owners",
"daily_average_standardized_tps": "Daily Average Standardized Transactions Per Second (STPS)",
"daily_average_erc20_scaling": "Daily Average ERC20 Scaling",
"standardized_tps_today": "Standardized Transactions Per Second today",
"erc20_scaling_today": "ERC20 scaling today",
"user_operations": "User Operations",
"daily_average_uops": "Daily Average User Operations Per Second (UOPS)",
"daily_max_uops": "Daily Max User Operations Per Second",
"daily_average_uopb": "Daily Average User Operations Per Block (UOPB)",
"daily_average_acps": "Daily Average Account Calls Per Second (ACPS)",
"daily_max_acps": "Daily Max Account Calls Per Second",
"daily_average_acpb": "Daily Average Account Calls Per Block (ACPB)",
"number_upos_today": "Number of user operations per second today",
"max_recorded_uops_today": "Max recorded user operations per second today",
"number_uopb_today": "Number of user operations per block today",
"total_user_operations": "Total number of user operations today",
"number_acps_today": "Number of account calls per second today",
"max_recorded_acps_today": "Max recorded account calls per second today",
"number_acpb_today": "Number of account calls per block today",
"total_account_calls": "Total number of account calls today",
"relative_compute": "Relative Compute"
}
22 changes: 21 additions & 1 deletion ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,25 @@
"sierra_bytecode": "Sierra Bytecode",
"starknet_remix": "Starknet Remix",
"starknet_cli_starkli": "Starknet CLI (Starkli)",
"number_of_owners": "Number of owners"
"number_of_owners": "Number of owners",
"daily_average_standardized_tps": "Daily Average Standardized Transactions Per Second (STPS)",
"daily_average_erc20_scaling": "Daily Average ERC20 Scaling",
"standardized_tps_today": "Standardized Transactions Per Second today",
"erc20_scaling_today": "ERC20 scaling today",
"user_operations": "User Operations",
"daily_average_uops": "Daily Average User Operations Per Second (UOPS)",
"daily_max_uops": "Daily Max User Operations Per Second",
"daily_average_uopb": "Daily Average User Operations Per Block (UOPB)",
"daily_average_acps": "Daily Average Account Calls Per Second (ACPS)",
"daily_max_acps": "Daily Max Account Calls Per Second",
"daily_average_acpb": "Daily Average Account Calls Per Block (ACPB)",
"number_upos_today": "Number of user operations per second today",
"max_recorded_uops_today": "Max recorded user operations per second today",
"number_uopb_today": "Number of user operations per block today",
"total_user_operations": "Total number of user operations today",
"number_acps_today": "Number of account calls per second today",
"max_recorded_acps_today": "Max recorded account calls per second today",
"number_acpb_today": "Number of account calls per block today",
"total_account_calls": "Total number of account calls today",
"relative_compute": "Relative Compute"
}
Loading

0 comments on commit 3b9b467

Please sign in to comment.