Skip to content

Commit 12fe75e

Browse files
authored
Merge pull request microsoft#1740 from iclanton/ianc/publish-loc-package
[localization-plugin] Prepare to publish the plugin package.
2 parents 298770b + caa25c7 commit 12fe75e

36 files changed

+1740
-735
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,21 @@ module.exports = function(env) {
4343
plugins: [
4444
new webpack.optimize.ModuleConcatenationPlugin(),
4545
new LocalizationPlugin({
46-
localizedStrings: {},
47-
defaultLocale: {
48-
usePassthroughLocale: true
46+
localizedData: {
47+
defaultLocale: {
48+
localeName: 'en-us'
49+
},
50+
passthroughLocale: {
51+
usePassthroughLocale: true
52+
}
4953
},
5054
typingsOptions: {
5155
generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts'),
5256
sourceRoot: path.resolve(__dirname, 'src')
5357
},
54-
localizationStatsDropPath: path.resolve(__dirname, 'temp', 'localization-stats.json')
58+
localizationStats: {
59+
dropPath: path.resolve(__dirname, 'temp', 'localization-stats.json')
60+
}
5561
}),
5662
new BundleAnalyzerPlugin({
5763
openAnalyzer: false,
@@ -63,8 +69,7 @@ module.exports = function(env) {
6369
}),
6470
new SetPublicPathPlugin({
6571
scriptName: {
66-
name: '[name]_[locale]_[contenthash].js',
67-
isTokenized: true
72+
useAssetName: true
6873
}
6974
}),
7075
new HtmlWebpackPlugin()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import(/* webpackChunkName: 'chunk-without-strings' */ './chunks/chunkWithoutStrings').then(({ ChunkWithoutStringsClass }) => {
2+
const chunk = new ChunkWithoutStringsClass();
3+
chunk.doStuff();
4+
});

build-tests/localization-plugin-test-02/src/strings3.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"comment": "the third string"
55
},
66
"string2": {
7-
"value": "string four",
7+
"value": "string four with an ' apostrophe",
88
"comment": "the fourth string"
99
},
1010
"string3": {

build-tests/localization-plugin-test-02/src/strings5.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@
6363
<value>"RESX string with quotemarks"</value>
6464
<comment>RESX string with quotemarks</comment>
6565
</data>
66+
<data name="unusedString" xml:space="preserve">
67+
<value>UNUSED STRING</value>
68+
<comment>UNUSED STRING</comment>
69+
</data>
6670
</root>

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

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
1010

1111
module.exports = function(env) {
1212
const configuration = {
13-
mode: 'production',
13+
mode: 'development',
1414
module: {
1515
rules: [
1616
{
@@ -31,6 +31,7 @@ module.exports = function(env) {
3131
entry: {
3232
'localization-test-A': path.join(__dirname, 'src', 'indexA.ts'),
3333
'localization-test-B': path.join(__dirname, 'src', 'indexB.ts'),
34+
'localization-test-C': path.join(__dirname, 'src', 'indexC.ts'),
3435
},
3536
output: {
3637
path: path.join(__dirname, 'dist'),
@@ -43,56 +44,40 @@ module.exports = function(env) {
4344
plugins: [
4445
new webpack.optimize.ModuleConcatenationPlugin(),
4546
new LocalizationPlugin({
46-
localizedStrings: {
47-
"en-us": {
48-
"./src/strings1.loc.json": {
49-
"string1": "the first string"
50-
},
51-
"./src/chunks/strings2.loc.json": {
52-
"string1": "the second string"
53-
},
54-
"./src/strings3.loc.json": {
55-
"string1": "the third string",
56-
"string2": "the fourth string",
57-
"string3": "UNUSED STRING!"
58-
},
59-
"./src/strings4.loc.json": {
60-
"string1": "\"String with quotemarks\""
61-
},
62-
"./src/strings5.resx": {
63-
"string1": "The first RESX string",
64-
"stringWithQuotes": "\"RESX string with quotemarks\""
65-
}
47+
localizedData: {
48+
defaultLocale: {
49+
localeName: 'en-us',
50+
fillMissingTranslationStrings: true
6651
},
67-
"es-es": {
68-
"./src/strings1.loc.json": {
69-
"string1": "la primera cadena"
70-
},
71-
"./src/chunks/strings2.loc.json": {
72-
"string1": "la segunda cadena"
73-
},
74-
"./src/strings3.loc.json": {
75-
"string1": "la tercera cadena",
76-
"string2": "la cuarta cadena",
77-
"string3": "UNUSED STRING!"
78-
},
79-
"./src/strings4.loc.json": {
80-
"string1": "\"Cadena con comillas\""
81-
},
82-
"./src/strings5.resx": {
83-
"string1": "La primera cadena RESX",
84-
"stringWithQuotes": "\"Cadena RESX con comillas\""
52+
translatedStrings: {
53+
"es-es": {
54+
"./src/strings1.loc.json": {
55+
"string1": "la primera cadena"
56+
},
57+
"./src/chunks/strings2.loc.json": {
58+
"string1": "la segunda cadena"
59+
},
60+
"./src/strings4.loc.json": {
61+
"string1": "\"Cadena con comillas\""
62+
},
63+
"./src/strings5.resx": {
64+
"string1": "La primera cadena RESX",
65+
"stringWithQuotes": "\"Cadena RESX con comillas\""
66+
}
8567
}
68+
},
69+
passthroughLocale: {
70+
usePassthroughLocale: true,
71+
passthroughLocaleName: 'default'
8672
}
8773
},
88-
defaultLocale: {
89-
usePassthroughLocale: true
90-
},
9174
typingsOptions: {
9275
generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts'),
9376
sourceRoot: path.resolve(__dirname, 'src')
9477
},
95-
localizationStatsDropPath: path.resolve(__dirname, 'temp', 'localization-stats.json')
78+
localizationStats: {
79+
dropPath: path.resolve(__dirname, 'temp', 'localization-stats.json')
80+
}
9681
}),
9782
new BundleAnalyzerPlugin({
9883
openAnalyzer: false,
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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="string" xml:space="preserve">
59+
<value>RESX string</value>
60+
<comment>RESX string</comment>
61+
</data>
62+
</root>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import strings2 from './strings2.loc.json';
2+
import strings6 from './strings6.resx';
3+
4+
export class UnnamedChunkWithStringsClass {
5+
public doStuff(): void {
6+
console.log(strings2.string1);
7+
console.log(strings6.string);
8+
}
9+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ import(/* webpackChunkName: 'chunk-without-strings' */ './chunks/chunkWithoutStr
1616
chunk.doStuff();
1717
});
1818

19+
import('./chunks/unnamedChunkWithStrings').then(({ UnnamedChunkWithStringsClass }) => {
20+
const chunk = new UnnamedChunkWithStringsClass();
21+
chunk.doStuff();
22+
});
23+
1924
console.log(strings5.string1);
20-
console.log(strings5.stringWithQuotes);
25+
console.log(strings5.stringWithQuotes);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import(/* webpackChunkName: 'chunk-with-strings' */ './chunks/chunkWithStrings').then(({ ChunkWithStringsClass }) => {
2+
const chunk = new ChunkWithStringsClass();
3+
chunk.doStuff();
4+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import(/* webpackChunkName: 'chunk-without-strings' */ './chunks/chunkWithoutStrings').then(({ ChunkWithoutStringsClass }) => {
2+
const chunk = new ChunkWithoutStringsClass();
3+
chunk.doStuff();
4+
});

0 commit comments

Comments
 (0)