Skip to content

Instantly share code, notes, and snippets.

View dragoon's full-sized avatar

Roman Prokofyev dragoon

View GitHub Profile
@dragoon
dragoon / add_translation.js
Last active May 4, 2023 07:35
Translate string to multiple languages with Google Translation API in Node.js (no dependecies)
const fs = require('fs');
const path = require('path');
const https = require('https');
const API_KEY = 'XXXX';
function translateText(text, targetLanguage) {
return new Promise((resolve, reject) => {
const url = `https://translation.googleapis.com/language/translate/v2?key=${API_KEY}&q=${encodeURIComponent(
text
@dragoon
dragoon / windows_app_store_gen.mjs
Created September 1, 2023 12:34
Generate multi-language store listing file for Microsoft store.
import TranslateModule from '@google-cloud/translate';
import fs from 'fs';
import csv from 'fast-csv';
import path from 'path';
// Initialize Google Translate API Client
const translate = new TranslateModule.v2.Translate();
const screenshotDir = 'output/screenshots/';
process.env['GOOGLE_APPLICATION_CREDENTIALS'] = 'credentials.json';