Browse Source

#18208 test deep nesting and add documentation

pull/23701/head
Jack Fistelmann 5 months ago
parent
commit
0a43d945d7
  1. 14
      docs/en/framework/fundamentals/localization.md
  2. 1
      framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs
  3. 5
      framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/SourceExt/en.json

14
docs/en/framework/fundamentals/localization.md

@ -91,6 +91,20 @@ A JSON localization file content is shown below:
> ABP will ignore (skip) the JSON file if the `culture` section is missing.
You may also use Nesting in your localization file
````json
{
"culture": "en",
"texts": {
"HelloWorld": "Hello World!",
"MyNestedTranslation": {
"SomeKey": "Some nested value"
}
}
}
````
### Default Resource
`AbpLocalizationOptions.DefaultResourceType` can be set to a resource type, so it is used when the localization resource was not specified:

1
framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs

@ -386,6 +386,7 @@ public class AbpLocalization_Tests : AbpIntegratedTest<AbpLocalizationTestModule
{
_localizer["MyNestedTranslation__SomeKey"].Value.ShouldBe("Some nested value");
_localizer["MyNestedTranslation__SomeOtherKey"].Value.ShouldBe("Some other nested value");
_localizer["MyNestedTranslation__DeeplyNested__DeepKey"].Value.ShouldBe("A deeply nested value");
}
}
}

5
framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/SourceExt/en.json

@ -4,7 +4,10 @@
"SeeYou": "See you",
"MyNestedTranslation": {
"SomeKey": "Some nested value",
"SomeOtherKey": "Some other nested value"
"SomeOtherKey": "Some other nested value",
"DeeplyNested": {
"DeepKey": "A deeply nested value"
}
}
}
}
Loading…
Cancel
Save