Skip to content

Commit eeb7f1c

Browse files
committed
localizations
1 parent 7692b0f commit eeb7f1c

20 files changed

+864
-32
lines changed

src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/EvaluatorSelector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static EvaluatorType ParseEvaluatorName(string? name, EvaluatorType? @d
7878
"C++" => EvaluatorType.CPP,
7979
"MSBUILD" => EvaluatorType.MSBuild,
8080
"VB" => EvaluatorType.VB,
81-
_ => throw new TemplateAuthoringException($"Unrecognized evaluator: '{evaluatorName}'.", evaluatorName),
81+
_ => throw new TemplateAuthoringException(string.Format(LocalizableStrings.EvaluatorSelector_Exception_UnknownEvaluator, evaluatorName)),
8282
};
8383
return evaluator;
8484
}

src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/LocalizableStrings.Designer.cs

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/LocalizableStrings.resx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,53 @@ Details: {1}</value>
195195
{1} - the comma separated list of sources (localized values) which define the binding
196196
{2} - the comma separated list of prefixes that can be used to define the source of the value</comment>
197197
</data>
198+
<data name="EvaluatorSelector_Exception_UnknownEvaluator" xml:space="preserve">
199+
<value>Unrecognized evaluator: '{0}'.</value>
200+
<comment>{0} - invalid evaluator value</comment>
201+
</data>
202+
<data name="JoinMacroConfig_Exception_ValuePropertyIsEmpty" xml:space="preserve">
203+
<value>Generated symbol '{0}': array '{1}' should contain JSON objects with property non-empty '{2}' when '{3}' is '{4}'.</value>
204+
<comment>{0} - name of generated symbol, {1} - the invalid property name; {2}, {3}, {4} - the property names and values.</comment>
205+
</data>
198206
<data name="LocalizationModelDeserializer_Error_FailedToParse" xml:space="preserve">
199207
<value>Failed to read parse localization file {0}, it will be skipped from further processing.</value>
200208
</data>
209+
<data name="MacroConfig_Exception_ArrayShouldContainObjects" xml:space="preserve">
210+
<value>Generated symbol '{0}': array '{1}' should contain JSON objects.</value>
211+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
212+
</data>
213+
<data name="MacroConfig_Exception_InvalidJSON" xml:space="preserve">
214+
<value>Generated symbol '{0}': '{1}' is not a valid JSON.</value>
215+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
216+
</data>
217+
<data name="MacroConfig_Exception_InvalidRegex" xml:space="preserve">
218+
<value>Generated symbol '{0}': the pattern '{1}' is invalid.</value>
219+
<comment>{0} - name of generated symbol, {1} - the invalid regex pattern</comment>
220+
</data>
221+
<data name="MacroConfig_Exception_MissingMandatoryProperty" xml:space="preserve">
222+
<value>Generated symbol '{0}' of type '{1}' should have '{2}' property defined.</value>
223+
<comment>{0} - name of generated symbol, {1} - the generated symbol type, {2} - the missing property.</comment>
224+
</data>
225+
<data name="MacroConfig_Exception_MissingValueProperty" xml:space="preserve">
226+
<value>Generated symbol '{0}': array '{1}' should contain JSON objects with property '{2}'.</value>
227+
<comment>{0} - name of generated symbol, {1} - the invalid property name; {2} - the missing property.</comment>
228+
</data>
229+
<data name="MacroConfig_Exception_ValueShouldBeArray" xml:space="preserve">
230+
<value>Generated symbol '{0}': '{1}' should be a valid JSON array.</value>
231+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
232+
</data>
233+
<data name="MacroConfig_Exception_ValueShouldBeBoolean" xml:space="preserve">
234+
<value>Generated symbol '{0}': '{1}' should be a boolean value.</value>
235+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
236+
</data>
237+
<data name="MacroConfig_Exception_ValueShouldBeInteger" xml:space="preserve">
238+
<value>Generated symbol '{0}': '{1}' should be an integer value.</value>
239+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
240+
</data>
241+
<data name="MacroConfig_Exception_ValueShouldBeString" xml:space="preserve">
242+
<value>Generated symbol '{0}': '{1}' should be a string value.</value>
243+
<comment>{0} - name of generated symbol, {1} - the invalid property name.</comment>
244+
</data>
201245
<data name="RunnableProjectConfig_OperationSetup_UnknownForm" xml:space="preserve">
202246
<value>The symbol '{0}': unable to find a form '{1}', the further processing of the symbol will be skipped.</value>
203247
<comment>{0} - the name of the symbol in configuration, {1} - the name of the form in configuration.</comment>

src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Macros/BaseMacroConfig.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ protected static bool ConvertJTokenToBool(string token, IGeneratedSymbolConfig c
7878
var jToken = JToken.Parse(token);
7979
if (jToken.Type is not JTokenType.Boolean and not JTokenType.String)
8080
{
81-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be a boolean value.", config.VariableName);
81+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeBoolean, config.VariableName, parameterName), config.VariableName);
8282
}
8383
if (bool.TryParse(jToken.ToString(), out bool result))
8484
{
8585
return result;
8686
}
87-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be a boolean value.", config.VariableName);
87+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeBoolean, config.VariableName, parameterName), config.VariableName);
8888
}
8989
catch (TemplateAuthoringException)
9090
{
9191
throw;
9292
}
9393
catch (Exception ex)
9494
{
95-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' is not a valid JSON.", config.VariableName, ex);
95+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_InvalidJSON, config.VariableName, parameterName), config.VariableName, ex);
9696
}
9797
}
9898

@@ -103,21 +103,21 @@ protected static int ConvertJTokenToInt(string token, IGeneratedSymbolConfig con
103103
var jToken = JToken.Parse(token);
104104
if (jToken.Type is not JTokenType.Integer and not JTokenType.String)
105105
{
106-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be an integer.", config.VariableName);
106+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeInteger, config.VariableName, parameterName), config.VariableName);
107107
}
108108
if (int.TryParse(jToken.ToString(), out int result))
109109
{
110110
return result;
111111
}
112-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be an integer.", config.VariableName);
112+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeInteger, config.VariableName, parameterName), config.VariableName);
113113
}
114114
catch (TemplateAuthoringException)
115115
{
116116
throw;
117117
}
118118
catch (Exception ex)
119119
{
120-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' is not a valid JSON.", config.VariableName, ex);
120+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_InvalidJSON, config.VariableName, parameterName), config.VariableName, ex);
121121
}
122122
}
123123

@@ -128,7 +128,7 @@ protected static string ConvertJTokenToString(string token, IGeneratedSymbolConf
128128
var jToken = JToken.Parse(token);
129129
if (jToken.Type != JTokenType.String)
130130
{
131-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be a string.", config.VariableName);
131+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeString, config.VariableName, parameterName), config.VariableName);
132132
}
133133
return jToken.ToString();
134134
}
@@ -138,7 +138,7 @@ protected static string ConvertJTokenToString(string token, IGeneratedSymbolConf
138138
}
139139
catch (Exception ex)
140140
{
141-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' is not a valid JSON.", config.VariableName, ex);
141+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_InvalidJSON, config.VariableName, parameterName), config.VariableName, ex);
142142
}
143143
}
144144

@@ -149,7 +149,7 @@ protected static JArray ConvertJTokenToJArray(string token, IGeneratedSymbolConf
149149
var jToken = JToken.Parse(token);
150150
if (jToken.Type != JTokenType.Array)
151151
{
152-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' should be a JSON array.", config.VariableName);
152+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_ValueShouldBeArray, config.VariableName, parameterName), config.VariableName);
153153
}
154154
return (JArray)jToken;
155155
}
@@ -159,7 +159,7 @@ protected static JArray ConvertJTokenToJArray(string token, IGeneratedSymbolConf
159159
}
160160
catch (Exception ex)
161161
{
162-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}': '{parameterName}' is not a valid JSON.", config.VariableName, ex);
162+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_InvalidJSON, config.VariableName, parameterName), config.VariableName, ex);
163163
}
164164
}
165165

@@ -173,7 +173,7 @@ protected static void IsValidRegex(string regex, IGeneratedSymbolConfig? generat
173173
{
174174
if (generatedSymbolConfig is not null)
175175
{
176-
throw new TemplateAuthoringException($"Generated symbol '{generatedSymbolConfig.VariableName}': the pattern '{regex}' is invalid.", generatedSymbolConfig.VariableName);
176+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_InvalidRegex, generatedSymbolConfig.VariableName, regex), generatedSymbolConfig.VariableName);
177177
}
178178
else
179179
{
@@ -186,7 +186,7 @@ protected string GetMandatoryParameterValue(IGeneratedSymbolConfig config, strin
186186
{
187187
if (!config.Parameters.TryGetValue(parameterName, out string token))
188188
{
189-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}' of type '{Type}' should have '{parameterName}' property defined.");
189+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_MissingMandatoryProperty, config.VariableName, Type, parameterName), config.VariableName);
190190
}
191191
return ConvertJTokenToString(token, config, parameterName);
192192
}
@@ -195,7 +195,7 @@ protected TVal GetMandatoryParameterValue<TVal>(IGeneratedSymbolConfig config, s
195195
{
196196
if (!config.Parameters.TryGetValue(parameterName, out string token))
197197
{
198-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}' of type '{Type}' should have '{parameterName}' property defined.");
198+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_MissingMandatoryProperty, config.VariableName, Type, parameterName), config.VariableName);
199199
}
200200
return converter(token, config, parameterName);
201201
}
@@ -204,7 +204,7 @@ protected JArray GetMandatoryParameterArray(IGeneratedSymbolConfig config, strin
204204
{
205205
if (!config.Parameters.TryGetValue(parameterName, out string token))
206206
{
207-
throw new TemplateAuthoringException($"Generated symbol '{config.VariableName}' of type '{Type}' should have '{parameterName}' property defined.");
207+
throw new TemplateAuthoringException(string.Format(LocalizableStrings.MacroConfig_Exception_MissingMandatoryProperty, config.VariableName, Type, parameterName), config.VariableName);
208208
}
209209
return ConvertJTokenToJArray(token, config, parameterName);
210210
}

0 commit comments

Comments
 (0)