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
function constructTranslationsForLanguage(lang, translations): Promise<any> { | |
return request(listTermsOptions) | |
.then(body => JSON.parse(body).result.terms) | |
.then(terms => { | |
for (const index in terms) { | |
if (terms.hasOwnProperty(index)) { | |
const term = encodeAsFirebaseKey(terms[index]['term']); | |
if (!translations[term]) { | |
translations[term] = {}; | |
} |
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
function constructTranslationsperLanguage(project_id: string): Promise<any> { | |
const translations = {}; | |
return request(listLanguagesOptions) | |
.then(response => JSON.parse(response).result.languages.map(lang => lang['code'])) | |
.then(languages => { | |
return Promise.all(languages.map(lang => { | |
listTermsOptions.formData.language = lang; | |
listTermsOptions.formData.id = project_id; | |
return constructTranslationsForLanguage(lang, translations) | |
})) |
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
import * as request from 'request-promise'; | |
import * as firebase from 'firebase'; | |
import * as admin from 'firebase-admin'; | |
import { projectId } from './poeditor-params'; | |
import { Project } from './project'; | |
import { listProjectOptions, listLanguagesOptions, listTermsOptions } from './api-options'; | |
import { blacklisted_projects } from './blacklisted_projects'; | |
const serviceAccount = require('./serviceAccountKey.json'); | |
firebase.initializeApp({ |
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
function writeTranslationsPerProject(projects: Project[]): void { | |
Promise.all(projects.map(project => { | |
listLanguagesOptions.formData.id = project.id; | |
return constructTranslationsperLanguage(project.id) | |
.then(translations => { | |
return firebase.database().ref('translations/' + project.name.replace('Winestep-', '') + '/').set(translations) | |
.then(() => console.log(project.name, 'done!')); | |
}) | |
})).then(() => process.exit()); | |
} |
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
function selectValidProjects(): Promise<Project[]> { | |
return request(listProjectOptions) | |
.then(response => JSON.parse(response).result.projects) | |
.then(projects => { | |
const projectsList: Project[] = []; | |
projects.forEach(project => { | |
if (!is_project_blacklisted(project)) { | |
projectsList.push({ | |
name: project['name'], | |
id: project['id'] |
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
import { api_key } from './poeditor-params'; | |
const listLanguageURI = 'https://api.poeditor.com/v2/languages/list'; | |
const listTermsURI = 'https://api.poeditor.com/v2/terms/list'; | |
const listProjectsURI = 'https://api.poeditor.com/v2/projects/list'; | |
// Options for reading the projects in POEditor | |
export const listProjectOptions = { | |
method: 'POST', | |
uri: listProjectsURI, |
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
import * as fs from 'fs'; | |
const languages = ['eng', 'fra', 'nl']; | |
const regex = /(\<x(\s+([^\/]*))\/\>)/gi; | |
languages.forEach(lang => { | |
const data: string = fs.readFileSync(`../../src/i18n/messages.${lang}.xlf`, 'utf-8'); | |
const dataLines: string[] = data.split('\n'); | |
const rewrittenData = dataLines.map((line: string) => { |
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
import * as fs from 'fs'; | |
const data: string = fs.readFileSync('../../i18n/messages.xlf', 'utf-8'); | |
const dataLines: string[] = data.split('\n'); | |
const regex = /(<x(\s+([^>]*))*\/>)/gi; | |
const rewrittenData = dataLines.map((line: string) => { | |
return line.replace(regex, '<x$2/>'); | |
}); |
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
<trans-unit id="5e4f32f1b3fa8e5261a2735d2ac4cccdda18a40b" datatype="html"> | |
<source> | |
<x id="START_TABLE_CELL" ctype="x-td" equiv-text="<td>"/>Original<x id="CLOSE_TABLE_CELL" ctype="x-td" equiv-text="</td>"/> | |
<x id="START_TABLE_CELL" ctype="x-td" equiv-text="<td>"/>Translated<x id="CLOSE_TABLE_CELL" ctype="x-td" equiv-text="</td>"/> | |
</source> | |
<context-group purpose="location"> | |
<context context-type="sourcefile">app/app.component.html</context> | |
<context context-type="linenumber">4</context> | |
</context-group> | |
</trans-unit> |
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
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: 'app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
public colors = ['blue', 'red', 'yellow']; | |
public language = 'eng'; |
NewerOlder