abpframework / abpframework/abp
why not work json sub root IStringLocalizer?
@maliming is already working on this.
Since May 22, 2023.
- Dominant language
- C#
- Stars
- 14.4k
- Forks
- 3.7k
- Avg merge
- 15h 32m
- Merged PRs (30d)
- 106
Description
It is possible that the JSON sub root is not working due to incorrect configuration or implementation of IStringLocalizer with JSON files. Here are some possible reasons why it may not be working.
file en.json :
{
"culture": "en",
"texts": {
{
"Order": {
"Total": "About Us",
"Product": {
"Name" : "Mobile",
"Code" : "Code sku",
}
},
"Home": {
"Title": "Home Page",
"Description": "This is the home page."
}
}
}
}
<label>@L["Order.Product.Name"]</label>
<label>@L["Order.Product.Code"]</label>
Error system :
'Can not parse json string. The JSON value could not be converted to System.String. Path: $.texts.Class | LineNumber: 6 | BytePositionInLine: 14.
So please add this code to abp.framework update version next for suport root json keys :
https://codewithmukesh.com/blog/json-based-localization-in-aspnet-core/
Or
https://stackoverflow.com/questions/43615912/asp-net-core-localization-with-json-files
And Sample code in cshtml:
<label>@L["Order.Product.Name"]</label>
<label>@L["Order.Product.Code"]</label>
This work .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.