-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool translations aren't forwarded to the front-end #982
Comments
solved this adding the following method to component file:
and then in component's boot method:
However, it overrides a bunch of other translations, which is not that great. Would love Nova to automatically include component translations in frontend. |
@maslauskas I've already tried very similar things... Nova::provideToScript([
'translations' => [
'proposal-items::' => __('proposal-editor::kpi')
],
]); Nova::$jsonVariables['translations']['proposal-items::'] = __('proposal-editor::kpi'); But nothing seems to work... |
Got it to work with this in component's boot method:
Basically just loading all translations again and providing them to frontend... Seems to me that at the time of passing json translations to frontend, component translations are not loaded yet, so maybe it's a simple issue of moving scripts around. |
@maslauskas Still no dice... When I dump out the results of your snippet ( -------- ------------------------------------------------------------
date Thu, 15 Nov 2018 16:09:07 +0100
source ToolServiceProvider.php on line 36
file nova-components\my-resource-tool\src\ToolServiceProvider.php
-------- ------------------------------------------------------------
"*" |
Very strange. For me this little hack works as expected. Hopefully they add something to Nova that would load all component translations to frontend soon. |
@maslauskas Still, this should be a core feature and not something that requires workarounds... |
This is still an issue with Nova 1.2.1 |
Nova provides translations to front using the following method: /**
* Get the translation keys from file.
*
* @return array
*/
private static function getTranslations()
{
$translationFile = resource_path('lang/vendor/nova/'.app()->getLocale().'.json');
if (! is_readable($translationFile)) {
return [];
}
return json_decode(file_get_contents($translationFile), true);
} Meaning you need to place your translations inside published |
Hey there! In order to keep this repository focused on bug reports, we auto-close feature requests and requests for help. Feel free to post your feature requests so others can discuss and add reactions. We'll keep an eye on them for later planning. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
As per Laravel 5.7 docs, I've added the translations to my tool, and in the blade templates / Tinker / ... it works fine. I've expected this to be added to the
Nova.config.translations
object automatically to be used with__()
, but that's not the case, only the Nova translations are added there.The
Nova::provideToScript([])
doesn't help in extending already present translations with the new ones.The text was updated successfully, but these errors were encountered: