https://github.com/angular/angular
Raw File
Tip revision: ed41bfcad7b88ef0a151d4b90bdc7c5c495ce7d1 authored by Jessica Janiuk on 08 February 2024, 18:36:38 UTC
release: cut the v17.2.0-rc.0 release
Tip revision: ed41bfc
update-xlf-translation-file.js
/**
 * This file simulates translating a generated translation file into a new locale.
 * In particular it takes an English locale XLIFF 1.2 format and translates to the French locale.
 */
const fs = require('fs');
const path = require('path');

// Load the file
const filePath = path.resolve(__dirname, '..', process.argv.pop());
const contents = fs.readFileSync(filePath, 'utf8');

// Backup the file
fs.writeFileSync(filePath + '.bak', contents, 'utf8');

// Write translated file
const updated =
    contents.replace(/source>/g, 'target>')
        .replace(/Hello/g, 'Bonjour')
        .replace(/source-language="([^"]+)"/g, 'source-language="$1" target-language="legacy"');
fs.writeFileSync(filePath, updated, 'utf8');
back to top