use string-prelude and poheader if it is present
This commit is contained in:
parent
0bd47e107c
commit
4ccdcf3058
@ -24,6 +24,8 @@ import * as fs from "fs";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import glob = require("glob");
|
import glob = require("glob");
|
||||||
|
|
||||||
|
const DEFAULT_STRING_PRELUDE = "export const strings: any = {};\n\n"
|
||||||
|
|
||||||
export function po2ts(): void {
|
export function po2ts(): void {
|
||||||
const files = glob.sync("src/i18n/*.po");
|
const files = glob.sync("src/i18n/*.po");
|
||||||
|
|
||||||
@ -34,9 +36,14 @@ export function po2ts(): void {
|
|||||||
|
|
||||||
console.log(files);
|
console.log(files);
|
||||||
|
|
||||||
const chunks: string[] = [
|
let prelude: string;
|
||||||
"export const strings: any = {};\n\n"
|
try {
|
||||||
];
|
prelude = fs.readFileSync("src/i18n/strings-prelude", "utf-8")
|
||||||
|
} catch (e) {
|
||||||
|
prelude = DEFAULT_STRING_PRELUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
const chunks = [prelude];
|
||||||
|
|
||||||
for (const filename of files) {
|
for (const filename of files) {
|
||||||
const m = filename.match(/([a-zA-Z0-9-_]+).po/);
|
const m = filename.match(/([a-zA-Z0-9-_]+).po/);
|
||||||
|
@ -21,6 +21,26 @@ import * as ts from "typescript";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
|
|
||||||
|
const DEFAULT_PO_HEADER = `# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the PACKAGE package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\\n"
|
||||||
|
"Report-Msgid-Bugs-To: \\n"
|
||||||
|
"POT-Creation-Date: 2016-11-23 00:00+0100\\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\\n"
|
||||||
|
"Language: \\n"
|
||||||
|
"MIME-Version: 1.0\\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\\n"\n\n`
|
||||||
|
|
||||||
|
|
||||||
function wordwrap(str: string, width: number = 80): string[] {
|
function wordwrap(str: string, width: number = 80): string[] {
|
||||||
var regex = ".{1," + width + "}(\\s|$)|\\S+(\\s|$)";
|
var regex = ".{1," + width + "}(\\s|$)|\\S+(\\s|$)";
|
||||||
return str.match(RegExp(regex, "g"));
|
return str.match(RegExp(regex, "g"));
|
||||||
@ -417,28 +437,14 @@ export function potextract() {
|
|||||||
!prog.isSourceFileDefaultLibrary(x),
|
!prog.isSourceFileDefaultLibrary(x),
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log(ownFiles.map((x) => x.fileName));
|
let header: string
|
||||||
|
try {
|
||||||
|
header = fs.readFileSync("src/i18n/poheader", "utf-8")
|
||||||
|
} catch (e) {
|
||||||
|
header = DEFAULT_PO_HEADER
|
||||||
|
}
|
||||||
|
|
||||||
const chunks = [];
|
const chunks = [header];
|
||||||
|
|
||||||
chunks.push(`# SOME DESCRIPTIVE TITLE.
|
|
||||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
||||||
# This file is distributed under the same license as the PACKAGE package.
|
|
||||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
||||||
#
|
|
||||||
#, fuzzy
|
|
||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: PACKAGE VERSION\\n"
|
|
||||||
"Report-Msgid-Bugs-To: \\n"
|
|
||||||
"POT-Creation-Date: 2016-11-23 00:00+0100\\n"
|
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
|
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\\n"
|
|
||||||
"Language: \\n"
|
|
||||||
"MIME-Version: 1.0\\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\\n"\n\n`);
|
|
||||||
|
|
||||||
const knownMessageIds = new Set<string>();
|
const knownMessageIds = new Set<string>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user