Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rudashi's avatar

JSON Localization

Hello Good people,

It's possible to create nested localization JSON? If yes, how I can access to this from blade template?

{
    "errors": {
       "auth.failed": "Wrong data",
       "auth.throttle": "Need to wait :seconds seconds"
    }
}
0 likes
4 replies
shakti's avatar

you have to use multidimensional array as per your requirement and then convert them into json format

Rudashi's avatar

But original file is resources/lang/*.json and I can't use typical arrays. Maybe it's possible to split file to section like VIEWS?

Rudashi's avatar

I'm simple man. Sorry I don't get it. Maybe I will try to explain more my problem. Here's a little bit of imaginary code:

*.json

{
    "users": {
        "Login":"Login",
        "Address Email":"E-mail"
    },
    "login": {
           "Login":"Sign In",
        "Address Email":"Email"
}

users.blade.php

{{ __('Login) }}  //gives Login

login.blade.php

{{ __('Login) }} //gives Sign In

Sometimes I need to use the same string, but in different page it has different meaning. If this question is too obvious, then I apologize. I just try to find solution.

Please or to participate in this conversation.