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

zidance's avatar

Can I create multiple file under 1 locale directory and merge into locale.json?

I am thinking how should I make the json file smaller by split it into multiple json for language.

For example, I have a en.json in my src/locales. I am thinking to create a directory named en and store all the related json into the created directory. After that I want to merge them into en.json.

How can I do this? Or any better suggestion?

0 likes
3 replies
bugsysha's avatar

I don't think there are objective answers to this question. I would keep it simple and leave everything in a single file. If you organize things properly you shouldn't have issues. Plus using the proper editor will help you fold sections so you can easily overview only the part that you are interested in.

zidance's avatar

@bugsysha But when put everything in one single file, will getting larger from time to time. Isn't good to have separate file to make it maintainable?

bugsysha's avatar

@zidance you will need more processing power to get all files and merge them together than you need just to read a big file. Unless you break it down to load only required files for the features that the user is currently using, you will not see any benefits. Even then I wouldn't break the file down, I would just cache things into smaller chunks if I can do the breakdown that I've mentioned. But that implementation might be more time-consuming than the value it brings.

Please or to participate in this conversation.