Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from mapachurro/rename-defs
Browse files Browse the repository at this point in the history
Rename defs
  • Loading branch information
mapachurro authored Apr 16, 2024
2 parents c0c1dd9 + a95151c commit 1aa5ac9
Show file tree
Hide file tree
Showing 38 changed files with 11,462 additions and 2,044 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: GitHub Pages

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Also does automated updates on PR
push:
branches:
- master
- main
pull_request:

jobs:
Expand All @@ -14,15 +18,15 @@ jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "21"

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -37,4 +41,4 @@ jobs:
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_dir: ./dist
790 changes: 395 additions & 395 deletions data/export-definitions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/exportTerms.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fs.readFile('consensys-termbase.json', 'utf8', (err, data) => {
term: englishTerm,
phonetic: '', // You may need to update this if phonetic is available in the JSON
partOfSpeech: '', // You may need to fill this later
description: termData['Definition'], // Using 'Definition' field as description
definition: termData['Definition'], // Using 'Definition' field as definition
termCategory: termData['Term category'] || '', // Using 'Term category' field if available
i18n: {},
};
Expand Down
42 changes: 42 additions & 0 deletions data/transExport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs');
const path = require('path');

const termsFilePath = path.join(__dirname, './consensys-termbase.json');
const localesDir = path.join(__dirname, './../src/i18n', 'locales');

const termsData = JSON.parse(fs.readFileSync(termsFilePath, 'utf8'));

for (const term of termsData) {
const i18nData = Object.entries(term).filter(([key]) => key !== 'Term' && key !== 'Definition' && key !== 'Term category');

for (const [locale, translation] of i18nData) {
const localeDir = path.join(localesDir, locale.toLowerCase());
const translationFilePath = path.join(localeDir, 'translation.json');

try {
// Create the locale directory if it doesn't exist
if (!fs.existsSync(localeDir)) {
fs.mkdirSync(localeDir, { recursive: true });
console.log(`Created directory: ${localeDir}`);
}

// Read the existing translation file or create a new one
let translationData = {};
if (fs.existsSync(translationFilePath)) {
translationData = JSON.parse(fs.readFileSync(translationFilePath, 'utf8'));
} else {
fs.writeFileSync(translationFilePath, '{}');
console.log(`Created file: ${translationFilePath}`);
}

// Add or update the term translation in the translation data
translationData[term.Term] = translation;

// Write the updated translation data to the file
fs.writeFileSync(translationFilePath, JSON.stringify(translationData, null, 2));
console.log(`Added term "${term.Term}" to ${translationFilePath}`);
} catch (err) {
console.error(`Error processing term "${term.Term}" for locale "${locale}":`, err);
}
}
}
Loading

0 comments on commit 1aa5ac9

Please sign in to comment.