diff options
Diffstat (limited to 'src/api')
5 files changed, 78 insertions, 12 deletions
diff --git a/src/api/wix/WixToolset.Data/Localization.cs b/src/api/wix/WixToolset.Data/Localization.cs index 70c096de..d7727f17 100644 --- a/src/api/wix/WixToolset.Data/Localization.cs +++ b/src/api/wix/WixToolset.Data/Localization.cs | |||
@@ -16,10 +16,19 @@ namespace WixToolset.Data | |||
16 | private readonly Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>(); | 16 | private readonly Dictionary<string, LocalizedControl> localizedControls = new Dictionary<string, LocalizedControl>(); |
17 | 17 | ||
18 | /// <summary> | 18 | /// <summary> |
19 | /// Instantiates a new localization object with default location. | ||
20 | /// </summary> | ||
21 | public Localization(int? codepage, int? summaryInformationCodepage, string culture, IDictionary<string, BindVariable> variables, IDictionary<string, LocalizedControl> localizedControls) : | ||
22 | this(LocalizationLocation.Source, codepage, summaryInformationCodepage, culture, variables, localizedControls) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | /// <summary> | ||
19 | /// Instantiates a new localization object. | 27 | /// Instantiates a new localization object. |
20 | /// </summary> | 28 | /// </summary> |
21 | public Localization(int? codepage, int? summaryInformationCodepage, string culture, IDictionary<string, BindVariable> variables, IDictionary<string, LocalizedControl> localizedControls) | 29 | public Localization(LocalizationLocation location, int? codepage, int? summaryInformationCodepage, string culture, IDictionary<string, BindVariable> variables, IDictionary<string, LocalizedControl> localizedControls) |
22 | { | 30 | { |
31 | this.Location = location; | ||
23 | this.Codepage = codepage; | 32 | this.Codepage = codepage; |
24 | this.SummaryInformationCodepage = summaryInformationCodepage; | 33 | this.SummaryInformationCodepage = summaryInformationCodepage; |
25 | this.Culture = culture?.ToLowerInvariant() ?? String.Empty; | 34 | this.Culture = culture?.ToLowerInvariant() ?? String.Empty; |
@@ -28,6 +37,11 @@ namespace WixToolset.Data | |||
28 | } | 37 | } |
29 | 38 | ||
30 | /// <summary> | 39 | /// <summary> |
40 | /// Gets the location the localization came from. | ||
41 | /// </summary> | ||
42 | public LocalizationLocation Location { get; private set; } | ||
43 | |||
44 | /// <summary> | ||
31 | /// Gets the codepage. | 45 | /// Gets the codepage. |
32 | /// </summary> | 46 | /// </summary> |
33 | /// <value>The codepage.</value> | 47 | /// <value>The codepage.</value> |
@@ -57,9 +71,27 @@ namespace WixToolset.Data | |||
57 | /// <value>The localized controls.</value> | 71 | /// <value>The localized controls.</value> |
58 | public ICollection<KeyValuePair<string, LocalizedControl>> LocalizedControls => this.localizedControls; | 72 | public ICollection<KeyValuePair<string, LocalizedControl>> LocalizedControls => this.localizedControls; |
59 | 73 | ||
74 | /// <summary> | ||
75 | /// Updates the location, if the location is a higher state than the current state. | ||
76 | /// </summary> | ||
77 | /// <param name="location">Location to update to.</param> | ||
78 | /// <returns>This localization object.</returns> | ||
79 | public Localization UpdateLocation(LocalizationLocation location) | ||
80 | { | ||
81 | if (this.Location < location) | ||
82 | { | ||
83 | this.Location = location; | ||
84 | } | ||
85 | |||
86 | return this; | ||
87 | } | ||
88 | |||
60 | internal JsonObject Serialize() | 89 | internal JsonObject Serialize() |
61 | { | 90 | { |
62 | var jsonObject = new JsonObject(); | 91 | var jsonObject = new JsonObject() |
92 | { | ||
93 | { "location", this.Location.ToString().ToLowerInvariant() } | ||
94 | }; | ||
63 | 95 | ||
64 | if (this.Codepage.HasValue) | 96 | if (this.Codepage.HasValue) |
65 | { | 97 | { |
@@ -108,6 +140,7 @@ namespace WixToolset.Data | |||
108 | 140 | ||
109 | internal static Localization Deserialize(JsonObject jsonObject) | 141 | internal static Localization Deserialize(JsonObject jsonObject) |
110 | { | 142 | { |
143 | var location = jsonObject.GetEnumOrDefault("location", LocalizationLocation.Source); | ||
111 | var codepage = jsonObject.GetValueOrDefault("codepage", null); | 144 | var codepage = jsonObject.GetValueOrDefault("codepage", null); |
112 | var summaryCodepage = jsonObject.GetValueOrDefault("summaryCodepage", null); | 145 | var summaryCodepage = jsonObject.GetValueOrDefault("summaryCodepage", null); |
113 | var culture = jsonObject.GetValueOrDefault<string>("culture"); | 146 | var culture = jsonObject.GetValueOrDefault<string>("culture"); |
@@ -131,7 +164,7 @@ namespace WixToolset.Data | |||
131 | } | 164 | } |
132 | } | 165 | } |
133 | 166 | ||
134 | return new Localization(codepage, summaryCodepage, culture, variables, controls); | 167 | return new Localization(location, codepage, summaryCodepage, culture, variables, controls); |
135 | } | 168 | } |
136 | } | 169 | } |
137 | } | 170 | } |
diff --git a/src/api/wix/WixToolset.Data/LocalizationLocation.cs b/src/api/wix/WixToolset.Data/LocalizationLocation.cs new file mode 100644 index 00000000..773c4d9f --- /dev/null +++ b/src/api/wix/WixToolset.Data/LocalizationLocation.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.Data | ||
4 | { | ||
5 | /// <summary> | ||
6 | /// Location where the localization was loaded. | ||
7 | /// </summary> | ||
8 | public enum LocalizationLocation | ||
9 | { | ||
10 | /// <summary> | ||
11 | /// Localization loaded from .wxl source file. | ||
12 | /// </summary> | ||
13 | Source, | ||
14 | |||
15 | /// <summary> | ||
16 | /// Localization loaded from .wixlib library. | ||
17 | /// </summary> | ||
18 | Library, | ||
19 | |||
20 | /// <summary> | ||
21 | /// Localization loaded from .wixlib library within .wixext WixExtension. | ||
22 | /// </summary> | ||
23 | Extension, | ||
24 | |||
25 | /// <summary> | ||
26 | /// Localization placed in .wixext WixExtension as the default culture localization for the | ||
27 | /// WixExtension. | ||
28 | /// </summary> | ||
29 | ExtensionDefaultCulture | ||
30 | } | ||
31 | } | ||
diff --git a/src/api/wix/WixToolset.Data/LocalizedControl.cs b/src/api/wix/WixToolset.Data/LocalizedControl.cs index 1252842b..9f59ce46 100644 --- a/src/api/wix/WixToolset.Data/LocalizedControl.cs +++ b/src/api/wix/WixToolset.Data/LocalizedControl.cs | |||
@@ -45,7 +45,10 @@ namespace WixToolset.Data | |||
45 | /// Get key for a localized control. | 45 | /// Get key for a localized control. |
46 | /// </summary> | 46 | /// </summary> |
47 | /// <returns>The localized control id.</returns> | 47 | /// <returns>The localized control id.</returns> |
48 | public string GetKey() => LocalizedControl.GetKey(this.Dialog, this.Control); | 48 | public string GetKey() |
49 | { | ||
50 | return LocalizedControl.GetKey(this.Dialog, this.Control); | ||
51 | } | ||
49 | 52 | ||
50 | /// <summary> | 53 | /// <summary> |
51 | /// Get key for a localized control. | 54 | /// Get key for a localized control. |
@@ -53,7 +56,10 @@ namespace WixToolset.Data | |||
53 | /// <param name="dialog">The optional id of the control's dialog.</param> | 56 | /// <param name="dialog">The optional id of the control's dialog.</param> |
54 | /// <param name="control">The id of the control.</param> | 57 | /// <param name="control">The id of the control.</param> |
55 | /// <returns>The localized control id.</returns> | 58 | /// <returns>The localized control id.</returns> |
56 | public static string GetKey(string dialog, string control) => String.Concat(dialog, "/", control); | 59 | public static string GetKey(string dialog, string control) |
60 | { | ||
61 | return String.Concat(dialog, "/", control); | ||
62 | } | ||
57 | 63 | ||
58 | internal JsonObject Serialize() | 64 | internal JsonObject Serialize() |
59 | { | 65 | { |
diff --git a/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs b/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs index e4a10fd9..291b1014 100644 --- a/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs +++ b/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
4 | { | 4 | { |
5 | using System; | ||
5 | using WixToolset.Data; | 6 | using WixToolset.Data; |
6 | 7 | ||
7 | /// <summary> | 8 | /// <summary> |
@@ -10,8 +11,9 @@ namespace WixToolset.Extensibility | |||
10 | public abstract class BaseExtensionData : IExtensionData | 11 | public abstract class BaseExtensionData : IExtensionData |
11 | { | 12 | { |
12 | /// <summary> | 13 | /// <summary> |
13 | /// See <see cref="IExtensionData.DefaultCulture"/> | 14 | /// Obsolete in WiX v5. Use the WixLocalization/@ExtensionDefaultCulture attribute in the wxl file instead. |
14 | /// </summary> | 15 | /// </summary> |
16 | [Obsolete("Set the ExtensionDefaultCulture attribute in the WixLocalization source file instead.")] | ||
15 | public virtual string DefaultCulture => null; | 17 | public virtual string DefaultCulture => null; |
16 | 18 | ||
17 | /// <summary> | 19 | /// <summary> |
diff --git a/src/api/wix/WixToolset.Extensibility/IExtensionData.cs b/src/api/wix/WixToolset.Extensibility/IExtensionData.cs index 823e2beb..e6565f4a 100644 --- a/src/api/wix/WixToolset.Extensibility/IExtensionData.cs +++ b/src/api/wix/WixToolset.Extensibility/IExtensionData.cs | |||
@@ -10,12 +10,6 @@ namespace WixToolset.Extensibility | |||
10 | public interface IExtensionData | 10 | public interface IExtensionData |
11 | { | 11 | { |
12 | /// <summary> | 12 | /// <summary> |
13 | /// Gets the optional default culture. | ||
14 | /// </summary> | ||
15 | /// <value>The optional default culture.</value> | ||
16 | string DefaultCulture { get; } | ||
17 | |||
18 | /// <summary> | ||
19 | /// | 13 | /// |
20 | /// </summary> | 14 | /// </summary> |
21 | /// <param name="name"></param> | 15 | /// <param name="name"></param> |