Skip to content

Commit 6147f69

Browse files
committed
Implement transform output mode
1 parent 2d9da0e commit 6147f69

File tree

9 files changed

+586
-53
lines changed

9 files changed

+586
-53
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
- [BREAKING] The `tsOut` parameter is replaced by the new `output` object with
11-
`mode: "runtime"`. Other outputs modes will follow.
11+
`mode: "runtime"|"transform"`.
12+
13+
- Add `transform` output mode, which emits an entire copy of the program in each
14+
locale, where all `msg` calls have been replaced with the raw translated
15+
template for that locale.
1216

1317
- Add ability to generate a `setLocale` function by setting
1418
`output.exportSetLocaleFunction: true`.

src/outputters/runtime.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {applyPatches, Patches} from '../patches';
1414
import {Locale} from '../locales';
1515
import {Config} from '../config';
1616
import {KnownError} from '../error';
17+
import {escapeStringLiteral} from '../typescript';
1718
import * as fs from 'fs';
1819
import * as pathLib from 'path';
1920

@@ -460,14 +461,3 @@ function makeMessageString(
460461
return msgStr;
461462
}
462463
}
463-
464-
/**
465-
* Escape a string such that it can be safely embedded in a JavaScript template
466-
* literal (backtick string).
467-
*/
468-
function escapeStringLiteral(unescaped: string): string {
469-
return unescaped
470-
.replace(`\\`, `\\\\`)
471-
.replace('`', '\\`')
472-
.replace('$', '\\$');
473-
}

0 commit comments

Comments
 (0)