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="2aj123dsa81327d9812312dsa234fs234" datatype="html"> | |
<source>This is a translatable string!</source> | |
<context-group purpose="location"> | |
<context context-type="sourcefile">app.component.ts</context> | |
<context context-type="linenumber">1</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
<div class="container"> | |
<h1 i18n>Translations</h1> | |
<table> | |
<tr i18n> | |
<td>Original</td> | |
<td>Translated</td> | |
</tr> | |
<tr *ngFor="let color of colors"> | |
<td>{{color}}</td> <!-- Will not be translated --> | |
<td>{{color | translate: language: 'colors' | async}}</td> <!-- Will be translated --> |
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 { first, map } from 'rxjs/operators'; | |
import { Injectable } from '@angular/core'; | |
import { AngularFireDatabase } from '@angular/fire/database'; | |
@Injectable() | |
export class TranslateService { | |
constructor(private angularFireDatabase: AngularFireDatabase) {} | |
/* Function which does the actual translation. We assume that the terms will always be translated from English to another language */ | |
translateFromEng(term: string, country_code: string, table: string): Promise<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 { Pipe, PipeTransform } from '@angular/core'; | |
import { TranslateService } from './translate.service'; | |
@Pipe({ | |
name: 'translate' | |
}) | |
export class TranslatePipe implements PipeTransform { | |
constructor(private translateService: TranslateService) {} | |
/* Pipe which translates term to the specified language |
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'; |
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 * 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
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 { 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
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'] |
OlderNewer