statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.11k stars 538 forks source link

Lang files are not loaded #11101

Closed kazak71 closed 2 weeks ago

kazak71 commented 2 weeks ago

Bug description

I made bulgarian translations of lang files (bg folder with message files and bg.json) and place them in lang/vendor/statamic folder. By changing locale to 'bg' nothing happens, but when I place these files in statamic/cms package (vendor/statamic/cms/resources/lang) everithing works fine.

How to reproduce

Publish translations, make a copy of en.json to bg.json, change any strings, change locale in .env to 'bg' and you will not see any changes.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.30.0
PHP Version: 8.2.20
Composer Version: 2.5.4
Environment: local
Debug Mode: ENABLED
URL: statamic.test
Maintenance Mode: OFF
Timezone: UTC
Locale: bg

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.37.0 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

ebeauchamps commented 2 weeks ago

"...but when I place these files in statamic/cms package (vendor/statamic/cms/resources/lang) everything works fine."

This is the intended location for all Lang files indeed.

kazak71 commented 2 weeks ago

ebeauchamps thank you for your reply! But according to laravel documentation If I put files in /lang/vendor/statamic they should work. And they don't work. It is not a good idea to modify the installed package directly (in /vendor/statamic/cms/... folder).

jasonvarga commented 2 weeks ago

Only php language files can be overridden in the lang/vendor/statamic directory. The json files need to just go in lang.

Ideally you would do like @ebeauchamps has said and contribute the translations into Statamic itself, but I understand maybe you want to do this temporarily.

kazak71 commented 2 weeks ago

I put files like this: /lang/vendor/statamic/bg.json /lang/vendor/statamic/bg/messahes.php ... And nothing works. When I put these files (bg.json and bg folder with php files) in /vendor/statamic/cms/resources/lang only json file is translated. Here is screenshot: Screen Shot 2024-11-11 at 12 53 43

duncanmcclean commented 2 weeks ago

It seems to be working fine for me 🤔

Can you share your lang files?

jasonvarga commented 2 weeks ago

I put files like this: /lang/vendor/statamic/bg.json /lang/vendor/statamic/bg/messahes.php ...

You need to do this:

/lang/bg.json /lang/vendor/statamic/bg/messages.php