|
4 | 4 | import {
|
5 | 5 | JsonFile,
|
6 | 6 | FileSystem,
|
7 |
| - Terminal |
| 7 | + Terminal, |
| 8 | + NewlineKind |
8 | 9 | } from '@rushstack/node-core-library';
|
9 | 10 | import * as Webpack from 'webpack';
|
10 | 11 | import * as path from 'path';
|
@@ -111,6 +112,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
|
111 | 112 | private _noStringsLocaleName: string;
|
112 | 113 | private _fillMissingTranslationStrings: boolean;
|
113 | 114 | private _pseudolocalizers: Map<string, (str: string) => string> = new Map<string, (str: string) => string>();
|
| 115 | + private _resxNewlineNormalization: NewlineKind | undefined; |
114 | 116 |
|
115 | 117 | /**
|
116 | 118 | * The outermost map's keys are the locale names.
|
@@ -173,7 +175,8 @@ export class LocalizationPlugin implements Webpack.Plugin {
|
173 | 175 | pluginInstance: this,
|
174 | 176 | configuration: compiler.options,
|
175 | 177 | filesToIgnore: this._filesToIgnore,
|
176 |
| - localeNameOrPlaceholder: Constants.LOCALE_NAME_PLACEHOLDER |
| 178 | + localeNameOrPlaceholder: Constants.LOCALE_NAME_PLACEHOLDER, |
| 179 | + resxNewlineNormalization: this._resxNewlineNormalization |
177 | 180 | };
|
178 | 181 |
|
179 | 182 | if (errors.length > 0 || warnings.length > 0) {
|
@@ -432,7 +435,8 @@ export class LocalizationPlugin implements Webpack.Plugin {
|
432 | 435 | const localizationFile: ILocalizationFile = LocFileParser.parseLocFile({
|
433 | 436 | filePath: localizedData,
|
434 | 437 | content: FileSystem.readFile(localizedData),
|
435 |
| - terminal: terminal |
| 438 | + terminal: terminal, |
| 439 | + resxNewlineNormalization: this._resxNewlineNormalization |
436 | 440 | });
|
437 | 441 |
|
438 | 442 | return this._convertLocalizationFileToLocData(localizationFile);
|
@@ -690,6 +694,30 @@ export class LocalizationPlugin implements Webpack.Plugin {
|
690 | 694 | }
|
691 | 695 | }
|
692 | 696 | // END options.localizedData.pseudoLocales
|
| 697 | + |
| 698 | + // START options.localizedData.normalizeResxNewlines |
| 699 | + if (this._options.localizedData.normalizeResxNewlines) { |
| 700 | + switch (this._options.localizedData.normalizeResxNewlines) { |
| 701 | + case 'crlf': { |
| 702 | + this._resxNewlineNormalization = NewlineKind.CrLf; |
| 703 | + break; |
| 704 | + } |
| 705 | + |
| 706 | + case 'lf': { |
| 707 | + this._resxNewlineNormalization = NewlineKind.Lf; |
| 708 | + break; |
| 709 | + } |
| 710 | + |
| 711 | + default: { |
| 712 | + errors.push(new Error( |
| 713 | + `Unexpected value "${this._options.localizedData.normalizeResxNewlines}" for option ` + |
| 714 | + '"localizedData.normalizeResxNewlines"' |
| 715 | + )); |
| 716 | + break; |
| 717 | + } |
| 718 | + } |
| 719 | + } |
| 720 | + // END options.localizedData.normalizeResxNewlines |
693 | 721 | } else if (!isWebpackDevServer) {
|
694 | 722 | throw new Error('Localized data must be provided unless webpack dev server is running.');
|
695 | 723 | }
|
|
0 commit comments