Skip to content

Commit bc0e747

Browse files
committed
rename and move localizations
1 parent f9e3b1c commit bc0e747

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

dsc/locales/en-us.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ noResources = "Resources not specified"
100100
resourceTypeNotSpecified = "Resource type not specified"
101101
validatingResource = "Validating resource named"
102102
resourceNotFound = "Resource type not found"
103-
resourceImplementsValidate = "Resource implements validation"
104-
noReason = "No reason provided"
105-
resourceValidationFailed = "Resource failed validation"
106-
resourceDoesNotImplementValidate = "Resource does not implement validation, using schema"
107-
noSchemaOrValidate = "Resource does not have a schema nor supports validation"
108-
noManifest = "Resource does not have a manifest"
109103
tableHeader_type = "Type"
110104
tableHeader_kind = "Kind"
111105
tableHeader_version = "Version"
@@ -127,9 +121,6 @@ failedToConvertJsonToString = "Failed to convert JSON to string"
127121
failedToReadTracingSetting = "Could not read 'tracing' setting"
128122
invalidTraceLevel = "Default to 'warn', invalid DSC_TRACE_LEVEL value"
129123
failedToSetTracing = "Unable to set global default tracing subscriber. Tracing is disabled."
130-
validatingSchema = "Validating against schema"
131-
failedToCompileSchema = "JSON Schema Compilation"
132-
validationFailed = "Failed validation"
133124
readingInput = "Reading input from command line parameter"
134125
inputIsFile = "Document provided is a file path, use '--file' instead"
135126
readingInputFromFile = "Reading input from file"

dsc_lib/locales/en-us.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ diffKeyMissing = "diff: key '%{key}' missing"
177177
diffKeyNotObject = "diff: key '%{key}' is not an object"
178178
diffArraySize = "diff: arrays have different lengths"
179179
diffMissingItem = "diff: actual array missing expected item"
180+
failedToCompileSchema = "JSON Schema Compilation"
181+
noManifest = "Resource does not have a manifest"
182+
noReason = "No reason provided"
183+
noSchemaOrValidate = "Resource does not have a schema nor supports validation"
184+
resourceDoesNotImplementValidate = "Resource does not implement validation, using schema"
185+
resourceImplementsValidate = "Resource implements validation"
186+
resourceValidationFailed = "Resource failed validation"
187+
validatingSchema = "Validating against schema"
188+
validationFailed = "Failed validation"
180189

181190
[dscresources.resource_manifest]
182191
resourceManifestSchemaTitle = "Resource manifest schema URI"

dsc_lib/src/dscresources/dscresource.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,24 +588,24 @@ pub fn validate_properties(resource: &DscResource, properties: &Value) -> Result
588588
// convert to resource_manifest``
589589
let manifest: ResourceManifest = serde_json::from_value(manifest)?;
590590
if manifest.validate.is_some() {
591-
debug!("{}: {type_name} ", t!("subcommand.resourceImplementsValidate"));
591+
debug!("{}: {type_name} ", t!("dscresources.dscresource.resourceImplementsValidate"));
592592
let resource_config = properties.to_string();
593593
let result = resource.validate(&resource_config)?;
594594
if !result.valid {
595-
let reason = result.reason.unwrap_or(t!("subcommand.noReason").to_string());
596-
return Err(DscError::Validation(format!("{}: {type_name} {reason}", t!("subcommand.resourceValidationFailed"))));
595+
let reason = result.reason.unwrap_or(t!("dscresources.dscresource.noReason").to_string());
596+
return Err(DscError::Validation(format!("{}: {type_name} {reason}", t!("dscresources.dscresource.resourceValidationFailed"))));
597597
}
598598
return Ok(())
599599
}
600600
// use schema validation
601-
trace!("{}: {type_name}", t!("subcommand.resourceDoesNotImplementValidate"));
601+
trace!("{}: {type_name}", t!("dscresources.dscresource.resourceDoesNotImplementValidate"));
602602
let Ok(schema) = resource.schema() else {
603-
return Err(DscError::Validation(format!("{}: {type_name}", t!("subcommand.noSchemaOrValidate"))));
603+
return Err(DscError::Validation(format!("{}: {type_name}", t!("dscresources.dscresource.noSchemaOrValidate"))));
604604
};
605605
let schema = serde_json::from_str(&schema)?;
606606
return validate_json(&resource.type_name, &schema, properties)
607607
}
608-
Err(DscError::Validation(format!("{}: {type_name}", t!("subcommand.noManifest"))))
608+
Err(DscError::Validation(format!("{}: {type_name}", t!("dscresources.dscresource.noManifest"))))
609609
}
610610

611611
/// Validate the JSON against the schema.
@@ -624,18 +624,18 @@ pub fn validate_properties(resource: &DscResource, properties: &Value) -> Result
624624
///
625625
/// * `DscError` - The JSON is invalid
626626
pub fn validate_json(source: &str, schema: &Value, json: &Value) -> Result<(), DscError> {
627-
debug!("{}: {source}", t!("util.validatingSchema"));
627+
debug!("{}: {source}", t!("dscresources.dscresource.validatingSchema"));
628628
trace!("JSON: {json}");
629629
trace!("Schema: {schema}");
630630
let compiled_schema = match Validator::new(schema) {
631631
Ok(compiled_schema) => compiled_schema,
632632
Err(err) => {
633-
return Err(DscError::Validation(format!("{}: {err}", t!("util.failedToCompileSchema"))));
633+
return Err(DscError::Validation(format!("{}: {err}", t!("dscresources.dscresource.failedToCompileSchema"))));
634634
}
635635
};
636636

637637
if let Err(err) = compiled_schema.validate(json) {
638-
return Err(DscError::Validation(format!("{}: '{source}' {err}", t!("util.validationFailed"))));
638+
return Err(DscError::Validation(format!("{}: '{source}' {err}", t!("dscresources.dscresource.validationFailed"))));
639639
}
640640

641641
Ok(())

0 commit comments

Comments
 (0)