abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.77k stars 3.41k forks source link

why not work json sub root IStringLocalizer? #16615

Open vioKamran opened 1 year ago

vioKamran commented 1 year ago

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 .

vioKamran commented 1 year ago

@maliming Thankyou for add backlog.

only one question : How long do you think it will take to fix this bug? Because this code is not very long and I think it will take an hour to replace all the framework codes.

maliming commented 1 year ago

We can be compatible with both.

vioKamran commented 1 year ago

Ok very thank you so much 🙏😊