https://github.com/angular/angular
Raw File
Tip revision: ae34e6cabdb6b7d4e6332ac18e94c7d6c28c7191 authored by Paul Gschwendtner on 10 January 2023, 14:04:24 UTC
fix(language-service): expose `package.json` for vscode extension resolution (#48678)
Tip revision: ae34e6c
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