diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-30 17:09:15 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-30 17:09:15 -0800 |
commit | c5190ae74ab8fe13609362efce88fa4b8cc24f34 (patch) | |
tree | e7762224afad491c37b70bab13756552c72fdd26 /src/WixToolset.Core/Localizer.cs | |
parent | d4f73e72985dc2f36e4228358f4dc9b6114414ab (diff) | |
download | wix-c5190ae74ab8fe13609362efce88fa4b8cc24f34.tar.gz wix-c5190ae74ab8fe13609362efce88fa4b8cc24f34.tar.bz2 wix-c5190ae74ab8fe13609362efce88fa4b8cc24f34.zip |
Fix resolution of localizations that are embedded in intermediates
Diffstat (limited to 'src/WixToolset.Core/Localizer.cs')
-rw-r--r-- | src/WixToolset.Core/Localizer.cs | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/src/WixToolset.Core/Localizer.cs b/src/WixToolset.Core/Localizer.cs index 2e7b19b6..38d8864e 100644 --- a/src/WixToolset.Core/Localizer.cs +++ b/src/WixToolset.Core/Localizer.cs | |||
@@ -14,72 +14,11 @@ namespace WixToolset.Core | |||
14 | /// <summary> | 14 | /// <summary> |
15 | /// Parses localization files and localizes database values. | 15 | /// Parses localization files and localizes database values. |
16 | /// </summary> | 16 | /// </summary> |
17 | public sealed class Localizer : ILocalizer | 17 | public sealed class Localizer |
18 | { | 18 | { |
19 | public static readonly XNamespace WxlNamespace = "http://wixtoolset.org/schemas/v4/wxl"; | 19 | public static readonly XNamespace WxlNamespace = "http://wixtoolset.org/schemas/v4/wxl"; |
20 | private static string XmlElementName = "WixLocalization"; | 20 | private static string XmlElementName = "WixLocalization"; |
21 | 21 | ||
22 | private Dictionary<string, BindVariable> variables; | ||
23 | private Dictionary<string, LocalizedControl> localizedControls; | ||
24 | |||
25 | /// <summary> | ||
26 | /// Instantiate a new Localizer. | ||
27 | /// </summary> | ||
28 | public Localizer(IMessaging messaging, IEnumerable<Localization> localizations) | ||
29 | { | ||
30 | this.Codepage = -1; | ||
31 | this.variables = new Dictionary<string, BindVariable>(); | ||
32 | this.localizedControls = new Dictionary<string, LocalizedControl>(); | ||
33 | |||
34 | foreach (var localization in localizations) | ||
35 | { | ||
36 | if (-1 == this.Codepage) | ||
37 | { | ||
38 | this.Codepage = localization.Codepage; | ||
39 | } | ||
40 | |||
41 | foreach (var variable in localization.Variables) | ||
42 | { | ||
43 | Localizer.AddWixVariable(messaging, this.variables, variable); | ||
44 | } | ||
45 | |||
46 | foreach (KeyValuePair<string, LocalizedControl> localizedControl in localization.LocalizedControls) | ||
47 | { | ||
48 | if (!this.localizedControls.ContainsKey(localizedControl.Key)) | ||
49 | { | ||
50 | this.localizedControls.Add(localizedControl.Key, localizedControl.Value); | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Gets the codepage. | ||
58 | /// </summary> | ||
59 | /// <value>The codepage.</value> | ||
60 | public int Codepage { get; } | ||
61 | |||
62 | /// <summary> | ||
63 | /// Get a localized data value. | ||
64 | /// </summary> | ||
65 | /// <param name="id">The name of the localization variable.</param> | ||
66 | /// <returns>The localized data value or null if it wasn't found.</returns> | ||
67 | public string GetLocalizedValue(string id) | ||
68 | { | ||
69 | return this.variables.TryGetValue(id, out var wixVariableRow) ? wixVariableRow.Value : null; | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Get a localized control. | ||
74 | /// </summary> | ||
75 | /// <param name="dialog">The optional id of the control's dialog.</param> | ||
76 | /// <param name="control">The id of the control.</param> | ||
77 | /// <returns>The localized control or null if it wasn't found.</returns> | ||
78 | public LocalizedControl GetLocalizedControl(string dialog, string control) | ||
79 | { | ||
80 | return this.localizedControls.TryGetValue(LocalizedControl.GetKey(dialog, control), out var localizedControl) ? localizedControl : null; | ||
81 | } | ||
82 | |||
83 | /// <summary> | 22 | /// <summary> |
84 | /// Loads a localization file from a path on disk. | 23 | /// Loads a localization file from a path on disk. |
85 | /// </summary> | 24 | /// </summary> |