Skip to content

Commit

Permalink
Updated translations and CI improvements for CrowdIn
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Jun 7, 2024
1 parent ecb473a commit 3ca052d
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ files:
- config.json
- custom.json
translation: /src/locales/%locale%/%original_file_name%
pull_request_title: "Update translations"
pull_request_labels: [
"i18n / l10n",
"CI run required"
]
6 changes: 3 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: npm install
- run: npm run build -- --pathPrefix="/stac-browser" --historyMode=hash
- uses: peaceiris/actions-gh-pages@v3
Expand All @@ -19,4 +19,4 @@ jobs:
publish_dir: dist
exclude_assets: 'report.html'
user_name: 'STAC Browser CI'
user_email: [email protected]
user_email: [email protected]
26 changes: 26 additions & 0 deletions .github/workflows/fix-i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Fix CrowdIn commits
on:
pull_request:
types:
- unlabeled
jobs:
deploy:
if: ${{ github.event.label.name == 'CI run required' }}
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- uses: actions/checkout@v4
- run: npm install
- run: node helpers/fix-crowdin.js
- name: Commit changes
run: |
git config user.name "STAC Browser CI"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u)
git commit -m ":robot: Automated update for locales: ${timestamp} [skip ci]" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions helpers/fix-crowdin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const fs = require('fs');
const path = require('path');

// Function to read JSON file
const readJsonFile = (filePath) => {
try {
const data = fs.readFileSync(filePath, 'utf8');
return JSON.parse(data);
} catch (err) {
console.error(`Error reading file from disk: ${err}`);
return null;
}
};

// Function to write JSON file
const writeJsonFile = (filePath, data) => {
try {
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + "\n", 'utf8');
console.log(`File has been written: ${filePath}`);
} catch (err) {
console.error(`Error writing file to disk: ${err}`);
}
};

// Function to remove empty strings from an object deeply
const removeEmptyStrings = (obj) => {
if (Array.isArray(obj)) {
return obj.map(removeEmptyStrings).filter((item) => item !== '');
} else if (obj !== null && typeof obj === 'object') {
return Object.entries(obj)
.filter(entry => entry[1] !== '')
.reduce((acc, [k, v]) => {
acc[k] = removeEmptyStrings(v);
return acc;
}, {});
}
return obj;
};

// Main function to process the locales directory
const processLocales = (localesDir) => {
const folders = fs.readdirSync(localesDir);

folders.forEach((folder) => {
const folderPath = path.join(localesDir, folder);

if (fs.statSync(folderPath).isDirectory()) {
['texts.json', 'fields.json'].forEach((fileName) => {
const filePath = path.join(folderPath, fileName);
if (fs.existsSync(filePath)) {
const jsonData = readJsonFile(filePath);
if (jsonData) {
const cleanedData = removeEmptyStrings(jsonData);
writeJsonFile(filePath, cleanedData);
}
}
});
}
});
};

// Execute the main function
processLocales('src/locales');
7 changes: 7 additions & 0 deletions src/locales/de/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
"Number": "Nummer",
"Number of Points": "Anzahl der Punkte",
"Number of bits": "Anzahl der Bits",
"Number of samples": "Anzahl an Proben",
"OGC Web Map Service (WMS)": "OGC Web Map Service (WMS)",
"OGC Web Map Tile Service (WMTS)": "Kartendienst: OGC WMTS",
"Observation Direction": "Beobachtungsrichtung",
Expand Down Expand Up @@ -293,6 +294,7 @@
"Path": "Pfad",
"Path Template": "Pfad-Vorlage",
"Pending (waiting for activation)": "Ausstehend (wartet auf Aktivierung)",
"Percentage of samples": "Prozentsatz der Proben",
"Percentage of valid pixels": "Prozentsatz der gültigen Pixel",
"Personal": "Persönlich",
"Phone": "Telefon",
Expand All @@ -316,7 +318,10 @@
"Processing Instructions": "Prozessierungsanweisungen",
"Processing Level": "Prozessierungslevel",
"Processing Status": "Status der Prozessierung",
"Processing Time": "Zeitpunkt der Prozessierung",
"Processing inctructions/code": "Prozessierungsanweisungen/-quelltext",
"Processor Version": "Prozessor-Version",
"Product": "Produkt",
"Product ID": "Produkt-Kennung",
"Product Type": "Produktart",
"Product Variant": "Produkt-Variante",
Expand Down Expand Up @@ -447,6 +452,8 @@
"Time of Data": "Zeitstempel der Daten",
"Time of Data begins": "Erster Zeitstempel der Daten",
"Time of Data ends": "Letzter Zeitstempel der Daten",
"Timeliness": "Zeitrahmen",
"Timeliness Category": "Zeitrahmen-Kategorie",
"Title": "Titel",
"Transformation Matrix": "Transformationsmatrix",
"Transparency": "Transparenz",
Expand Down
62 changes: 61 additions & 1 deletion src/locales/en-GB/texts.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,81 @@
{
"actions": {},
"anonymized": {
"title": "Anonymised"
},
"assets": {
"alternate": {},
"copyGdalVfsUrl": {},
"copyUrl": {},
"download": {},
"role": {}
},
"authentication": {
"button": {}
},
"catalog": {},
"catalogs": {
"filterByTitle": "Filter catalogues by title",
"filterByTitleAndMore": "Filter catalogues by title, description or keywords",
"noMatches": "No catalogues match the given search criteria."
},
"checkbox": {},
"deprecation": {},
"errors": {
"labels": {},
"noExternalAccess": "Accessing external catalogues is not allowed!"
},
"fullscreen": {},
"goBack": {},
"goToCollection": {},
"goToParent": {},
"index": {
"catalog": "Catalogue",
"specifyCatalog": "Please specify a STAC Catalogue or API..."
},
"items": {},
"leaflet": {
"stayLayer": {},
"zoom": {
"in": {},
"out": {}
}
},
"metadata": {},
"multiselect": {},
"pagination": {},
"protocol": {
"s3": {}
},
"providers": {
"role": {}
},
"read": {},
"search": {
"logical": {},
"sortOptions": {},
"tabs": {}
},
"sidebar": {
"switchCatalog": "Switch Catalogue"
},
"stacCatalog": "Catalogue | Catalogues"
"sort": {
"asc": {},
"desc": {}
},
"source": {
"language": {},
"share": {},
"validationParams": {},
"validationReport": {}
},
"stacCatalog": "Catalogue | Catalogues",
"table": {
"sort": {}
},
"tree": {},
"view": {
"list": {},
"tiles": {}
}
}
2 changes: 1 addition & 1 deletion src/locales/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,4 @@
"°E": "°E",
"°N": "°N",
"μm": "μm"
}
}
1 change: 1 addition & 0 deletions src/locales/ja/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
"title": "ソースデータ",
"valid": "有効",
"validating": "検証中...",
"validationParams": {},
"validationReport": {
"disclaimer": "検証レポートはスキーマに基づいて生成されますが、網羅していないことがあります。 これらはSTAC仕様とその拡張のすべてをカバーするわけではありません。 この検証レポートは、STACエンティティが仕様およびその拡張に完全に準拠している保証ではありません。",
"result": "結果",
Expand Down
21 changes: 7 additions & 14 deletions src/locales/ro/texts.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"actions": {
},
"actions": {},
"additionalResources": "Resurse suplimentare",
"anonymized": {
"title": "Anonimizat"
},
"assets": {
"alternate": {
},
"alternate": {},
"copyGdalVfsUrl": {
"generic": "Copiați link-ul GDAL VFS",
"withSource": "Copiați link-ul GDAL VFS al {source}"
Expand Down Expand Up @@ -99,8 +97,7 @@
"exit": "Ieși din modul ecran complet",
"show": "Vizualizați pe tot ecranul"
},
"goBack": {
},
"goBack": {},
"goToCollection": {
"description": "Accesați colecția asociată",
"descriptionWithTitle": "@:goToCollection.description: {title}",
Expand Down Expand Up @@ -208,8 +205,7 @@
"itemsPerPageDescription": "Număr de elemente solicitate pe pagină, max. {maxItems} elemente",
"lessThan": "mai puțin decât",
"likeOperatorDescription": "Puteți folosi metacaracterele. `_` se potrivește cu un singur caracter, `%` se potrivește cu orice număr de caractere. Pentru a căuta în mod specific un wildcard, trebuie să adăugați un `\\` în fața caracterului.",
"logical": {
},
"logical": {},
"matches": "corespunde cu",
"metaDescription": "Căutați în oferta de date a {title}.",
"modifyCriteria": "Vă rugăm să modificați criteriile de căutare.",
Expand All @@ -226,8 +222,7 @@
"title": "Titlu"
},
"spatialExtent": "Întinderea spațială",
"tabs": {
},
"tabs": {},
"temporalExtent": "Interval de timp",
"title": "Căutare"
},
Expand Down Expand Up @@ -273,10 +268,8 @@
"valid": "Valid",
"validating": "Validare...",
"validationNA": "n.a.",
"validationParams": {
},
"validationReport": {
}
"validationParams": {},
"validationReport": {}
},
"stacAssets": "Resursă | Resurse",
"stacCatalog": "Catalog | Cataloage",
Expand Down

0 comments on commit 3ca052d

Please sign in to comment.