Skip to content

Commit a076332

Browse files
authored
Merge pull request microsoft#1734 from iclanton/ianc/loc-plugin-resx
[localization-plugin] Add RESX support to the localization plugin.
2 parents 2405faa + c8b7233 commit a076332

24 files changed

Lines changed: 1246 additions & 406 deletions

build-tests/localization-plugin-test/build.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const child_process = require('child_process');
33
const path = require('path');
44
const process = require('process');
55

6-
const { LocJsonPreprocessor } = require('@rushstack/localization-plugin');
6+
const { LocFilePreprocessor } = require('@rushstack/localization-plugin');
77

88
function executeCommand(command) {
99
console.log('---> ' + command);
@@ -16,10 +16,11 @@ FileSystem.ensureEmptyFolder('dist');
1616
FileSystem.ensureEmptyFolder('lib');
1717
FileSystem.ensureEmptyFolder('temp');
1818

19-
LocJsonPreprocessor.preprocessLocJsonFiles({
19+
const preprocessor = new LocFilePreprocessor({
2020
srcFolder: path.resolve(__dirname, 'src'),
2121
generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts')
2222
});
23+
preprocessor.generateTypings();
2324

2425
// Run Webpack
2526
executeCommand('node node_modules/webpack-cli/bin/cli');

build-tests/localization-plugin-test/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"webpack": "~4.31.0",
1818
"webpack-bundle-analyzer": "~3.6.0",
1919
"webpack-cli": "~3.3.2",
20-
"webpack-dev-server": "~3.9.0"
20+
"webpack-dev-server": "~3.9.0",
21+
"html-webpack-plugin": "~3.2.0"
2122
}
2223
}

build-tests/localization-plugin-test/serve.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const child_process = require('child_process');
33
const path = require('path');
44
const process = require('process');
55

6-
const { LocJsonPreprocessor } = require('@rushstack/localization-plugin');
6+
const { LocFilePreprocessor } = require('@rushstack/localization-plugin');
77

88
function executeCommand(command) {
99
console.log('---> ' + command);
@@ -16,10 +16,11 @@ FileSystem.ensureEmptyFolder('dist');
1616
FileSystem.ensureEmptyFolder('lib');
1717
FileSystem.ensureEmptyFolder('temp');
1818

19-
LocJsonPreprocessor.preprocessLocJsonFiles({
19+
const preprocessor = new LocFilePreprocessor({
2020
srcFolder: path.resolve(__dirname, 'src'),
2121
generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts')
2222
});
23+
preprocessor.generateTypings();
2324

2425
// Run Webpack
2526
executeCommand('node node_modules/webpack-dev-server/bin/webpack-dev-server');

build-tests/localization-plugin-test/src/indexA.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { string1 } from './strings1.loc.json';
22
import * as strings2 from './strings3.loc.json';
3+
import * as strings5 from './strings5.resx';
34

45
console.log(string1);
56

@@ -14,3 +15,6 @@ import(/* webpackChunkName: 'chunk-without-strings' */ './chunks/chunkWithoutStr
1415
const chunk = new ChunkWithoutStringsClass();
1516
chunk.doStuff();
1617
});
18+
19+
console.log(strings5.string1);
20+
console.log(strings5.stringWithQuotes);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<root>
3+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
4+
<xsd:element name="root" msdata:IsDataSet="true">
5+
<xsd:complexType>
6+
<xsd:choice maxOccurs="unbounded">
7+
<xsd:element name="metadata">
8+
<xsd:complexType>
9+
<xsd:sequence>
10+
<xsd:element name="value" type="xsd:string" minOccurs="0"/>
11+
</xsd:sequence>
12+
<xsd:attribute name="name" type="xsd:string">
13+
</xsd:attribute>
14+
<xsd:attribute name="type" type="xsd:string">
15+
</xsd:attribute>
16+
<xsd:attribute name="mimetype" type="xsd:string">
17+
</xsd:attribute>
18+
</xsd:complexType>
19+
</xsd:element>
20+
<xsd:element name="assembly">
21+
<xsd:complexType>
22+
<xsd:attribute name="alias" type="xsd:string">
23+
</xsd:attribute>
24+
<xsd:attribute name="name" type="xsd:string">
25+
</xsd:attribute>
26+
</xsd:complexType>
27+
</xsd:element>
28+
<xsd:element name="data">
29+
<xsd:complexType>
30+
<xsd:sequence>
31+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
32+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
33+
</xsd:sequence>
34+
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1">
35+
</xsd:attribute>
36+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3">
37+
</xsd:attribute>
38+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4">
39+
</xsd:attribute>
40+
</xsd:complexType>
41+
</xsd:element>
42+
<xsd:element name="resheader">
43+
<xsd:complexType>
44+
<xsd:sequence>
45+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
46+
</xsd:sequence>
47+
<xsd:attribute name="name" type="xsd:string" use="required">
48+
</xsd:attribute>
49+
</xsd:complexType>
50+
</xsd:element>
51+
</xsd:choice>
52+
</xsd:complexType>
53+
</xsd:element>
54+
</xsd:schema>
55+
<resheader name="resmimetype">
56+
<value>text/microsoft-resx</value>
57+
</resheader>
58+
<data name="string1" xml:space="preserve">
59+
<value>The first RESX string</value>
60+
<comment>The first RESX string</comment>
61+
</data>
62+
<data name="stringWithQuotes" xml:space="preserve">
63+
<value>"RESX string with quotemarks"</value>
64+
<comment>RESX string with quotemarks</comment>
65+
</data>
66+
</root>

build-tests/localization-plugin-test/webpack.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const webpack = require('webpack');
66
const { LocalizationPlugin } = require('@rushstack/localization-plugin');
77
const { SetPublicPathPlugin } = require('@microsoft/set-webpack-public-path-plugin');
88
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
9+
const HtmlWebpackPlugin = require('html-webpack-plugin');
910

1011
module.exports = function(env) {
1112
const configuration = {
@@ -57,6 +58,10 @@ module.exports = function(env) {
5758
},
5859
"./src/strings4.loc.json": {
5960
"string1": "\"String with quotemarks\""
61+
},
62+
"./src/strings5.resx": {
63+
"string1": "The first RESX string",
64+
"stringWithQuotes": "\"RESX string with quotemarks\""
6065
}
6166
},
6267
"es-es": {
@@ -73,6 +78,10 @@ module.exports = function(env) {
7378
},
7479
"./src/strings4.loc.json": {
7580
"string1": "\"Cadena con comillas\""
81+
},
82+
"./src/strings5.resx": {
83+
"string1": "La primera cadena RESX",
84+
"stringWithQuotes": "\"Cadena RESX con comillas\""
7685
}
7786
}
7887
},
@@ -97,7 +106,8 @@ module.exports = function(env) {
97106
name: '[name]_[locale]_[contenthash].js',
98107
isTokenized: true
99108
}
100-
})
109+
}),
110+
new HtmlWebpackPlugin()
101111
]
102112
};
103113

common/config/rush/nonbrowser-approved-packages.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
"name": "@microsoft/api-extractor-model",
1515
"allowedCategories": [ "libraries" ]
1616
},
17-
{
18-
"name": "@rushstack/debug-certificate-manager",
19-
"allowedCategories": [ "libraries" ]
20-
},
2117
{
2218
"name": "@microsoft/decorators",
2319
"allowedCategories": [ "libraries" ]
@@ -158,6 +154,10 @@
158154
"name": "@pnpm/logger",
159155
"allowedCategories": [ "libraries" ]
160156
},
157+
{
158+
"name": "@rushstack/debug-certificate-manager",
159+
"allowedCategories": [ "libraries" ]
160+
},
161161
{
162162
"name": "@rushstack/eslint-config",
163163
"allowedCategories": [ "libraries", "tests" ]
@@ -390,6 +390,10 @@
390390
"name": "gulp-typescript",
391391
"allowedCategories": [ "libraries" ]
392392
},
393+
{
394+
"name": "html-webpack-plugin",
395+
"allowedCategories": [ "tests" ]
396+
},
393397
{
394398
"name": "https-proxy-agent",
395399
"allowedCategories": [ "libraries" ]
@@ -434,6 +438,10 @@
434438
"name": "jsdom",
435439
"allowedCategories": [ "libraries" ]
436440
},
441+
{
442+
"name": "json-loader",
443+
"allowedCategories": [ "libraries" ]
444+
},
437445
{
438446
"name": "loader-utils",
439447
"allowedCategories": [ "libraries" ]
@@ -610,6 +618,10 @@
610618
"name": "xml",
611619
"allowedCategories": [ "libraries" ]
612620
},
621+
{
622+
"name": "xmldoc",
623+
"allowedCategories": [ "libraries" ]
624+
},
613625
{
614626
"name": "yargs",
615627
"allowedCategories": [ "libraries" ]

0 commit comments

Comments
 (0)