Browse Source

Update localization docs with nesting and array examples

pull/23701/head
maliming 11 months ago
parent
commit
7f6032e0de
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 22
      docs/en/framework/fundamentals/localization.md

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

@ -91,20 +91,34 @@ A JSON localization file content is shown below:
> ABP will ignore (skip) the JSON file if the `culture` section is missing. > ABP will ignore (skip) the JSON file if the `culture` section is missing.
You may also use Nesting in your localization file You can also use nesting or array in localization files, like this:
````json ````json
{ {
"culture": "en", "culture": "en",
"texts": { "texts": {
"HelloWorld": "Hello World!", "HelloWorld": "Hello World!",
"MyNestedTranslation": { "Hello": {
"SomeKey": "Some nested value" "World": "Hello World!"
} },
"Hi":[
"Bye": "Bye World!"
"Hello": "Hello World!"
]
} }
} }
```` ````
Then you can use it like this:
> The double underscore (`__`) is used to separate the parent key from the child key.
````csharp
var str = L["Hello__World"]; // Hello World!
var str2 = L["Hi__0"]; // Bye World!
var str3 = L["Hi__1"]; // Hello World!
````
### Default Resource ### Default Resource
`AbpLocalizationOptions.DefaultResourceType` can be set to a resource type, so it is used when the localization resource was not specified: `AbpLocalizationOptions.DefaultResourceType` can be set to a resource type, so it is used when the localization resource was not specified:

Loading…
Cancel
Save