ryanmitchell / statamic-translation-manager

MIT License
8 stars 6 forks source link

Doesn't show any translations #12

Closed DanielDarrenJones closed 11 months ago

DanielDarrenJones commented 11 months ago

Expected behavior: Translations to be loaded and shown in the plugin control page.

Actual behavior: No items are shown, and no translations are found:

Screenshot 2023-11-29 at 16 14 45 Screenshot 2023-11-29 at 16 14 38

Reproduce steps: Add translations .json file to lang folder, I have added an en.json, and then used the translation in the antlers code like so {{ trans key="accommodation-grid.no-results" }}, I have then gone to the control panel and its not displaying any items and not finding any translations when I click either button.

I'm not sure if I am missing a installation step? But SQLite is installed and this isn't working across 3 environments (2 local, 1 on Laravel Forge).

Version: ryanmitchell/statamic-translation-manager: 1.2.1

Additional Information: (Additional information, if any)

ryanmitchell commented 11 months ago

That’s strange. Would you be able to provide a repository that shows the issue?

DanielDarrenJones commented 11 months ago

@ryanmitchell It seems to break if you add the lang files directly under resources/lang

I have added two files an en_GB.json and en_US.json both with the following content:

{
    "accommodation-grid.no-results": "No accommodation found."
}

I'm not using a folder here as I don't need to separate the translations out and don't want to have to prefix all my translations, this works in the frontend fine.

If I add the folder eg. resources/lang/en_GB/site.json then the manager loads properly, however I then need to prefix all my translations with site. eg site.accommodation-grid.no-results

ryanmitchell commented 11 months ago

Translations in the json file are not meant to be dotted - you should use strings not keys. See: https://laravel.com/docs/10.x/localization#using-translation-strings-as-keys

DanielDarrenJones commented 11 months ago

I don't think this is the issue, it still doesnt work, even when not using dot seperation eg:

{
    "This is a test.": "No accommodation found."
}