Skip to content

Commit a784dd4

Browse files
committed
complete i18n work
1 parent 5568739 commit a784dd4

26 files changed

+480
-215
lines changed

dsc_lib/locales/en-us.toml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,244 @@ progressSearching = "Searching for resources"
7878
foundResourceManifest = "Found resource manifest: #{path}"
7979
adapterFound = "Resource adapter '#{adapter}' found"
8080
resourceFound = "Resource '#{resource}' found"
81+
82+
[dscresources.commandResource]
83+
invokeGet = "Invoking get for '#{resource}'"
84+
invokeGetUsing = "Invoking get '#{resource}' using '#{executable}'"
85+
verifyOutputUsing = "Verifying output of get '#{resource}' using '#{executable}'"
86+
groupGetResponse = "Group get response: #{response}"
87+
failedParseJson = "Failed to parse JSON from get #{executable}|#{stdout}|#{stderr} -> #{err}"
88+
invokeSet = "Invoking set for '#{resource}'"
89+
noPretest = "No pretest, invoking test on '#{resource}'"
90+
syntheticWhatIf = "cannot process what-if execution type, as resource implements pre-test and does not support what-if"
91+
setGetCurrent = "Getting current state for set by invoking get on '#{resource}' using '#{executable}'"
92+
setVerifyGet = "Verifying output of get on '#{resource}' using '#{executable}'"
93+
setVerifyOutput = "Verifying output of #{operation} '#{resource}' using '#{executable}'"
94+
setUnexpectedOutput = "Command did not return expected actual output"
95+
setUnexpectedDiff = "Command did not return expected diff output"
96+
invokeTest = "Invoking test for '#{resource}'"
97+
testSyntheticTest = "Resource '#{resource}' does not implement test, performing synthetic test"
98+
invokeTestUsing = "Invoking test on '#{resource}' using '{executable}'"
99+
testVerifyOutput = "Verifying output of test on '#{resource}' using '#{executable}'"
100+
testGroupTestResponse = "Import resource kind, returning group test response"
101+
testNoActualState = "No actual state returned"
102+
testNoDiff = "No diff properties returned"
103+
invokeDeleteUsing = "Invoking delete on '#{resource}' using '#{executable}'"
104+
invokeValidateConfig = "Invoking validate on '#{resource}' using '#{config}'"
105+
invokeVaalidateUsing = "Invoking validate on '#{resource}' using '#{executable}'"
106+
exportNotSupported = "Export is not supported by resource '#{resource}'"
107+
exportVerifyOutput = "Verifying output of export on '#{resource}' using '#{executable}'"
108+
resolveNotSupported = "Resolve is not supported by resource '#{resource}'"
109+
invokeResolveUsing = "Invoking resolve on '#{resource}' using '#{executable}'"
110+
processChildStdout = "child process did not have a handle to stdout"
111+
processChildStderr = "child process did not have a handle to stderr"
112+
processChildStdin = "child process did not have a handle to stdin"
113+
processWriteStdin = "could not write to stdin"
114+
processChildId = "Can't get child process id"
115+
processChildExit = "Process '#{executable}' id #{id} exited with code #{code}"
116+
processChildTerminated = "Process '#{executable}' id #{id} terminated by signal"
117+
processTerminated = "Process terminated by signal"
118+
commandInvoke = "Invoking command '#{executable}' with args #{args}"
119+
noArgs = "No args to process"
120+
parseAsEnvVars = "Parsing input as environment variables"
121+
parseAsStdin = "Parsing input as stdin"
122+
noInput = "No input kind specified"
123+
verifyJson = "Verify JSON for '#{resource}'"
124+
validateJson = "Validating against JSON: #{json}"
125+
resourceInvalidJson = "Resource reported input JSON is not valid"
126+
invalidArrayKey = "Unsupported array value for key '#{key}'. Only string and number is supported."
127+
invalidKey = "Unsupported value for key '#{key}'. Only string, bool, number, and array is supported."
128+
129+
[dscresources.dscresource]
130+
invokeGet = "Invoking get for '#{resource}'"
131+
customResourceNotSupported = "Custom resource not supported"
132+
invokeSet = "Invoking set for '#{resource}'"
133+
invokeTest = "Invoking test for '#{resource}'"
134+
invokeDelete = "Invoking delete for '#{resource}'"
135+
invokeValidate = "Invoking validate for '#{resource}'"
136+
invokeSchema = "Invoking schema for '#{resource}'"
137+
invokeExport = "Invoking export for '#{resource}'"
138+
invokeResolve = "Invoking resolve for '#{resource}'"
139+
subDiff = "diff: sub diff for '#{key}'"
140+
diffArray = "diff: arrays differ for '#{key}'"
141+
diffNotArray = "diff: '#{key}' is not an array"
142+
diffKeyMissing = "diff: key '#{key}' missing"
143+
diffKeyNotObject = "diff: key '#{key}' is not an object"
144+
diffArraySize = "diff: arrays have different lengths"
145+
diffMissingItem = "diff: actual array missing expected item"
146+
147+
[functions]
148+
invalidArgType = "Invalid argument type"
149+
invalidArguments = "Invalid argument(s)"
150+
unknownFunction = "Unknown function '#{name}'"
151+
noArgsAccepted = "Function '#{name}' does not accept arguments"
152+
invalidArgCount = "Function '#{name}' requires exactly #{count} arguments"
153+
minArgsRequired = "Function '#{name}' requires at least #{count} arguments"
154+
argCountRequired = "Function '#{name}' requires between #{min_args} and #{max_args} arguments"
155+
noArrayArgs = "Function '#{name}' does not accept array arguments, accepted types are: #{accepted_args_string}"
156+
noBooleanArgs = "Function '#{name}' does not accept boolean arguments, accepted types are: #{accepted_args_string}"
157+
noNumberArgs = "Function '#{name}' does not accept number arguments, accepted types are: #{accepted_args_string}"
158+
noObjectArgs = "Function '#{name}' does not accept object arguments, accepted types are: #{accepted_args_string}"
159+
noStringArgs = "Function '#{name}' does not accept string arguments, accepted types are: #{accepted_args_string}"
160+
161+
[functions.add]
162+
invoked = "add function"
163+
164+
[functions.concat]
165+
invoked = "concat function"
166+
argsMustBeStrings = "Arguments must all be strings"
167+
argsMustBeArrays = "Arguments must all be arrays"
168+
onlyArraysOfStrings = "Arguments must all be arrays of strings"
169+
170+
[functions.createArray]
171+
invoked = "createArray function"
172+
argsMustAllBeArrays = "Arguments must all be arrays"
173+
argsMustAllBeIntegers = "Arguments must all be integers"
174+
argsMustAllBeObjects = "Arguments must all be objects"
175+
argsMustAllBeStrings = "Arguments must all be strings"
176+
177+
[functions.div]
178+
invoked = "div function"
179+
divideByZero = "Cannot divide by zero"
180+
181+
[functions.envvar]
182+
notFound = "Environment variable not found"
183+
184+
[functions.int]
185+
invalidInput = "invalid input string"
186+
parseStringError = "unable to parse string to int"
187+
castError = "unable to cast to int"
188+
parseNumError = "unable to parse number to int"
189+
190+
[functions.max]
191+
emptyArray = "Array cannot be empty"
192+
integersOnly = "Array must contain only integers"
193+
noMax = "Unable to find max value"
194+
195+
[functions.min]
196+
invoked = "min function"
197+
emptyArray = "Array cannot be empty"
198+
integersOnly = "Input must only contain integers"
199+
noMin = "Unable to find min value"
200+
201+
[functions.mod]
202+
divideByZero = "Cannot divide by zero"
203+
204+
[functions.mul]
205+
invoked = "mul function"
206+
207+
[functions.parameters]
208+
invoked = "parameters function"
209+
traceKey = "parameters key: #{key}"
210+
keyNotString = "Parameter '#{key}' is not a string"
211+
keyNotFound = "Parameter '#{key}' not found in context"
212+
213+
[functions.path]
214+
traceArgs = "Executing path function with args: #{args}"
215+
argsMustBeStrings = "Arguments must all be strings"
216+
217+
[functions.reference]
218+
invoked = "reference function"
219+
keyNotFound = "Invalid resourceId or resource has not executed yet: #{key}"
220+
221+
[functions.resourceId]
222+
incorrectTypeFormat = "Type argument must contain exactly one slash"
223+
invalidFirstArgType = "Invalid argument type for first parameter"
224+
incorrectNameFormat = "Name argument cannot contain a slash"
225+
invalidSecondArgType = "Invalid argument type for second parameter"
226+
227+
[functions.sub]
228+
invoked = "sub function"
229+
230+
[functions.systemRoot]
231+
invoked = "systemRoot function"
232+
233+
[functions.variables]
234+
invoked = "variables function"
235+
keyNotFound = "Variable '#{key}' does not exist or has not been initialized yet"
236+
237+
[parser.expression]
238+
functionNodeNotFound = "Function node not found"
239+
parsingFunction = "Parsing function '#{name}'"
240+
parsingAccessor = "Parsing accessor '#{name}'"
241+
accessorParsingError = "Error parsing accessor"
242+
parsingMemberAccessor = "Parsing member accessor '#{name}'"
243+
memberNotFound = "Member name not found"
244+
parsingIndexAccessor = "Parsing index accessor '#{index}'"
245+
indexNotFound = "Index value not found"
246+
invalidAccessorKind = "Invalid accessor kind: '#{kind}'"
247+
functionResult = "Function results: #{results}"
248+
evalAccessors = "Evaluating accessors"
249+
memberNameNotFound = "Member '#{member}' not found"
250+
accessOnNonObject = "Member access on non-object value"
251+
expressionResult = "Expression result: #{result}"
252+
indexNotValid = "Index is not a valid number"
253+
indexOutOfBounds = "Index is out of bounds"
254+
indexOnNonArray = "Index access on non-array value"
255+
invalidIndexType = "Invalid index type"
256+
257+
[parser.functions]
258+
foundErrorNode = "Found error node parsing function"
259+
nameNodeNotFound = "Function name node not found"
260+
functionName = "Function name: '#{name}'"
261+
argIsExpression = "Argument is an expression"
262+
argIsValue = "Argument is a value: '#{value}'"
263+
unknownArgType = "Unknown argument type '#{kind}'"
264+
265+
[parser]
266+
parsingStatement = "Parsing statement: #{statement}"
267+
failedToParse = "Unable to parse: #{statement}"
268+
failedToParseRoot = "Unable to parse statement root: #{statement}"
269+
invalidStatement = "Invalid statement: #{statement}"
270+
failedToParseStringLiteral = "Unable to parse string literal"
271+
parsingStringLiteral = "Parsing string literal: #{value}"
272+
failedToParseEscapedStringLiteral = "Unable to parse escaped string literal"
273+
parsingEscapedStringLiteral = "Parsing escaped string literal: #{value}"
274+
parsingExpression = "Parsing expression"
275+
unknownExpressionType = "Unknown expression type: #{kind}"
276+
277+
[dscerror]
278+
adapterNotFound = "Adapter not found"
279+
booleanConversion = "Function boolean argument conversion"
280+
exitCode = "exit code"
281+
commandResource = "Command: Resource"
282+
commandExecutable = "Command: Executable"
283+
manifestDescription = "manifest description"
284+
commandOperation = "Command: Operation"
285+
forExecutable = "for executable"
286+
function = "Function"
287+
error = "error"
288+
integerConversion = "Function integer argument conversion"
289+
invalidConfiguration = "Invalid configuration"
290+
unsupportedManifestVersion = "Unsupported manifest version"
291+
mustBe = "Must be"
292+
invalidFunctionParameterCount = "Invalid function parameter count for"
293+
expected = "expected"
294+
got = "got"
295+
language = "Language"
296+
manifest = "Manifest"
297+
missingManifest = "Missing manifest"
298+
adapterBasedResource = "Adapter based resource"
299+
missingRequires = "missing 'requires' property for resource"
300+
schemaMissing = "Schema missing from manifest"
301+
notImplemented = "Not implemented"
302+
notSupported = "Not supported"
303+
numberConversion = "Number conversion"
304+
operation = "Operation"
305+
parser = "Parser"
306+
progress = "Progress"
307+
resourceNotFound = "Resource not found"
308+
resourceManifestNotFound = "Resource manifest not found"
309+
schema = "Schema"
310+
schemaNotAvailable = "No Schema found and `validate` is not supported"
311+
securityContext = "Security context"
312+
utf8Conversion = "UTF-8 conversion"
313+
unkonwn = "Unknown"
314+
validation = "Validation"
315+
setting = "Setting"
316+
317+
[util]
318+
foundSetting = "Found setting '#{name}' in #{path}"
319+
notFoundSetting = "Setting '#{name}' not found in #{path}"
320+
failedToGetExePath = "Can't get 'dsc' executable path"
321+
settingNotFound = "Setting '#{name}' not found"

dsc_lib/src/dscerror.rs

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
use rust_i18n::t;
45
use std::str::Utf8Error;
56

67
use indicatif::style::TemplateError;
@@ -10,40 +11,40 @@ use tree_sitter::LanguageError;
1011

1112
#[derive(Error, Debug)]
1213
pub enum DscError {
13-
#[error("Adapter '{0}' not found")]
14+
#[error("{t}: {0}", t = t!("dscerror.adapterNotFound"))]
1415
AdapterNotFound(String),
1516

16-
#[error("Function boolean argument conversion error: {0}")]
17+
#[error("{t}: {0}", t = t!("dscerror.booleanConversion"))]
1718
BooleanConversion(#[from] std::str::ParseBoolError),
1819

19-
#[error("Command: Resource '{0}' [Exit code {1}] {2}")]
20+
#[error("{t} '{0}' [{t2} {1}] {2}", t = t!("dscerror.commandResource"), t2 = t!("dscerror.exitCode"))]
2021
Command(String, i32, String),
2122

22-
#[error("Command: Executable '{0}' [Exit code {1}] {2}")]
23+
#[error("{t} '{0}' [{t2} {1}] {2}", t = t!("dscerror.commandExecutable"), t2 = t!("dscerror.exitCode"))]
2324
CommandExit(String, i32, String),
2425

25-
#[error("Command: Resource '{0}' [Exit code {1}] manifest description: {2}")]
26+
#[error("{t} '{0}' [{t2} {1}] {t3}: {2}", t = t!("dscerror.commandResource"), t2 = t!("dscerror.exitCode"), t3 = t!("dscerror.manifestDescription"))]
2627
CommandExitFromManifest(String, i32, String),
2728

28-
#[error("CommandOperation: {0} for executable '{1}'")]
29+
#[error("{t} {0} {t2} '{1}'", t = t!("dscerror.commandOperation"), t2 = t!("dscerror.forExecutable"))]
2930
CommandOperation(String, String),
3031

31-
#[error("Function '{0}' error: {1}")]
32+
#[error("{t} '{0}' {t2}: {1}", t = t!("dscerror.function"), t2 = t!("dscerror.error"))]
3233
Function(String, String),
3334

34-
#[error("Function '{0}' error: {1}")]
35+
#[error("{t} '{0}' {t2}: {1}", t = t!("dscerror.function"), t2 = t!("dscerror.error"))]
3536
FunctionArg(String, String),
3637

37-
#[error("Function integer argument conversion error: {0}")]
38+
#[error("{t}: {0}", t = t!("dscerror.integerConversion"))]
3839
IntegerConversion(#[from] std::num::ParseIntError),
3940

40-
#[error("Invalid configuration:\n{0}")]
41+
#[error("{t}:\n{0}", t = t!("dscerror.invalidConfiguration"))]
4142
InvalidConfiguration(String),
4243

43-
#[error("Unsupported manifest version: {0}. Must be: {1}")]
44+
#[error("{t}: {0}. {t2}: {1}", t = t!("dscerror.unsupportedManifestVersion"), t2 = t!("dscerror.mustBe"))]
4445
InvalidManifestSchemaVersion(String, String),
4546

46-
#[error("Invalid function parameter count for '{0}', expected {1}, got {2}")]
47+
#[error("{t} '{0}', {t2} {1}, {t3} {2}", t = t!("dscerror.invalidFunctionParameterCount"), t2 = t!("dscerror.expected"), t3 = t!("dscerror.got"))]
4748
InvalidFunctionParameterCount(String, usize, usize),
4849

4950
#[error("IO: {0}")]
@@ -52,72 +53,72 @@ pub enum DscError {
5253
#[error("JSON: {0}")]
5354
Json(#[from] serde_json::Error),
5455

55-
#[error("Language: {0}")]
56+
#[error("{t}: {0}", t = t!("dscerror.language"))]
5657
Language(#[from] LanguageError),
5758

58-
#[error("Manifest: {0}\nJSON: {1}")]
59+
#[error("{t}: {0}\nJSON: {1}", t = t!("dscerror.manifest"))]
5960
Manifest(String, serde_json::Error),
6061

61-
#[error("Manifest: {0}\nYAML: {1}")]
62+
#[error("{t}: {0}\nYAML: {1}", t = t!("dscerror.manifest"))]
6263
ManifestYaml(String, serde_yaml::Error),
6364

64-
#[error("Missing manifest: {0}")]
65+
#[error("{t}: {0}", t = t!("dscerror.missingManifest"))]
6566
MissingManifest(String),
6667

67-
#[error("Adapter-based resource '{0}' missing 'requires' property for resource '{1}'")]
68+
#[error("{t} '{0}' {t2} '{1}'", t = t!("dscerror.adapterBasedResource"), t2 = t!("dscerror.missingRequires"))]
6869
MissingRequires(String, String),
6970

70-
#[error("Schema missing from manifest: {0}")]
71+
#[error("{t}: {0}", t = t!("dscerror.schemaMissing"))]
7172
MissingSchema(String),
7273

73-
#[error("Not implemented: {0}")]
74+
#[error("{t}: {0}", t = t!("dscerror.notImplemented"))]
7475
NotImplemented(String),
7576

76-
#[error("Not supported: {0}")]
77+
#[error("{t}: {0}", t = t!("dscerror.notSupported"))]
7778
NotSupported(String),
7879

79-
#[error("Number conversion error: {0}")]
80+
#[error("{t}: {0}", t = t!("dscerror.numberConversion"))]
8081
NumberConversion(#[from] std::num::TryFromIntError),
8182

82-
#[error("Operation: {0}")]
83+
#[error("{t}: {0}", t = t!("dscerror.operation"))]
8384
Operation(String),
8485

85-
#[error("Parser: {0}")]
86+
#[error("{t}: {0}", t = t!("dscerror.parser"))]
8687
Parser(String),
8788

88-
#[error("Progress: {0}")]
89+
#[error("{t}: {0}", t = t!("dscerror.progress"))]
8990
Progress(#[from] TemplateError),
9091

91-
#[error("Resource not found: {0}")]
92+
#[error("{t}: {0}", t = t!("dscerror.resourceNotFound"))]
9293
ResourceNotFound(String),
9394

94-
#[error("Resource manifest not found: {0}")]
95+
#[error("{t}: {0}", t = t!("dscerror.resourceManifestNotFound"))]
9596
ResourceManifestNotFound(String),
9697

97-
#[error("Schema: {0}")]
98+
#[error("{t}: {0}", t = t!("dscerror.schema"))]
9899
Schema(String),
99100

100-
#[error("No Schema found and `validate` is not supported: {0}")]
101+
#[error("{t}: {0}", t = t!("dscerror.schemaNotAvailable"))]
101102
SchemaNotAvailable(String),
102103

103-
#[error("Security context: {0}")]
104+
#[error("{t}: {0}", t = t!("dscerror.securityContext"))]
104105
SecurityContext(String),
105106

106-
#[error("Utf-8 conversion error: {0}")]
107+
#[error("{t}: {0}", t = t!("dscerror.utf8Conversion"))]
107108
Utf8Conversion(#[from] Utf8Error),
108109

109-
#[error("Unknown: {code:?} {message:?}")]
110+
#[error("{t}: {code:?} {message:?}", t = t!("dscerror.unknown"))]
110111
Unknown {
111112
code: i32,
112113
message: String,
113114
},
114115

115-
#[error("Validation: {0}")]
116+
#[error("{t}: {0}", t = t!("dscerror.validation"))]
116117
Validation(String),
117118

118119
#[error("YAML: {0}")]
119120
Yaml(#[from] serde_yaml::Error),
120121

121-
#[error("Setting: {0}")]
122+
#[error("{t}: {0}", t = t!("dscerror.setting"))]
122123
Setting(String),
123124
}

0 commit comments

Comments
 (0)