Closed mstaack closed 3 years ago
@mstaack is it possible you have a different locale set than the default "en" ?
no using locale="en" has the same effect for some weird reason. the menu item is correctly translated, its just the panel header.
Same here
I think I can at least help a bit with finding the solution (if I had the whole solution I'd PR it, but unfortunately I don't): In your SettingsController's get method you call the translations, but for some reason the vendor translations are not yet loaded at that point. As a proof of concept try making a json file in your resources/lang
folder (in my case de.json
) and put the translation for novaSettings.navigationItemTitle
in there. That will work. So the "regular" translations are loaded when the controller ist fired, but the vendor translations are not yet loaded... or so it seems.
class SettingsController extends Controller
{
use ResolvesFields, ConditionallyLoadsAttributes;
public function get(Request $request)
{
$fields = $this->assignToPanels(__('novaSettings.navigationItemTitle'), $this->availableFields());
$panels = $this->panelsWithDefaultLabel(__('novaSettings.navigationItemTitle'), app(NovaRequest::class));
// more code
}
}
What version of Laravel and Nova are you guys running? I can't reproduce this issue.
I'm on Laravel 8.11.2 and Nova 3.14.0
I am on Nova 3.15.0 and Laravel 8.14.0
If you cannot reproduce it with those versions, I will try with a fresh install.
laravel/framework v8.14.0
laravel/nova 3.15.0
optimistdigital/nova-settings 2.5.6
Ah yes, I think I finally fixed it. It's due to Laravel Translator not working as intended. I worked around it for now, but I also opened up an issue here: https://github.com/laravel/framework/issues/35244
Try out version 2.5.7 and let me know if it works now. :) Thanks!
thanks for your effort, butthis broke only the menu item translation:
- Upgrading optimistdigital/nova-settings (2.5.6 => 2.5.7)
- Upgrading optimistdigital/nova-translations-loader (2.0.0 => 2.0.1)
also published translations again...
some context:
gives:
"novaSettings.navigationItemTitle"
"de"
of course en and de translations published.
Maybe something with the hints in app('translator')
instance? i am not really into laravel's translation logic/engine
Illuminate\Translation\Translator {#563
#loader: Illuminate\Translation\FileLoader {#562
#files: Illuminate\Filesystem\Filesystem {#38}
#path: "/Users/user/project/resources/lang"
#jsonPaths: array:3 [
0 => "/Users/user/project/resources/lang/vendor/nova"
1 => "/Users/user/project/vendor/optimistdigital/nova-multiselect-field/src/../resources/lang"
2 => "/Users/user/project/resources/lang/vendor/nova-settings"
]
#hints: array:5 [
"auth-checker" => "/Users/user/project/vendor/lab404/laravel-auth-checker/src/../lang/"
"backup" => "/Users/user/project/vendor/spatie/laravel-backup/src/../resources/lang/"
"enum" => "/Users/user/project/vendor/spatie/laravel-enum/src/../resources/lang/"
"nova-permission-tool" => "/Users/user/project/vendor/vyuldashev/nova-permission/src/../resources/lang"
"nova" => "/Users/user/project/vendor/laravel/nova/src/../resources/lang"
]
}
#locale: "de"
#fallback: "en"
maybe going with php arrays instead of json files is needed here!?
similar to: https://github.com/vyuldashev/nova-permission/tree/master/resources/lang/en
Going with php arrays is a clean way to do this (I do this in my Nova packages, too). You also would need less boilerplate code, as it is only two lines in your service provider.
But on the other hand this will be a breaking change for those who already use the json files to translate to their own language.
The problem with that is the fact that Nova doesn't know how to load translations for the front-end from the arrays.
Alright, released a new version - 2.5.8. Let me know if it's any better now. Seemed to work for me.
great! all working fine for me. 👍
Hi. I just want to share that the working version, for me, if used with Nova v2.12 is 2.5.0. Tried 2.5.8 but still got translation error.
My solution was:
create this file from en.json and translate!!! (for spanish)
resources/lang/vendor/nova-settings/es.json
Seeing
novaSettings.navigationItemTitle
in Settings View:I am on latest 2.5.6 and have all translations published.