MB's avatar
Level 2

Nova localization/translations

Hi,

I'm trying to translate some of the Nova application into my local language (danish).

I found this page: https://nova.laravel.com/docs/3.0/customization/localization.html

Tells me to create a copy of the lang file:

php artisan nova:translate dk
  • Works fine, file is created (I changed some text to test it).

At the end of the documentation it tells me to do the following:

To propagate your localizations to the frontend, you should call the Nova::translationsmethod within your NovaServiceProvider:

Nova::translations($pathToFile);

I'm not sure where to insert Nova::translations($pathToFile); and what the correct path is (file is named dk.json and is located in the lang/vendor/nova folder.

Any help is very appreciated

0 likes
3 replies
Maria30's avatar
Maria30
Best Answer
Level 20

@mb just change the

'locale' => 'dk'

at config/app.php

2 likes
MB's avatar
Level 2

Thank worked perfectly. Thanks!

Maria30's avatar

@mb my solution is good when you want one language for the whole application.

In case you want a different language for the website and another for the admin, check the solution at the bottom of this conversation: https://laracasts.com/discuss/channels/nova/force-nova-to-use-another-locale?page=1

At Providers/NovaServiceProvider

 public function boot()
    {

        Nova::serving(function (ServingNova $event) {
            app()->setLocale('dk');
        });

        parent::boot();


    }

I will also search how Nova::translations($pathToFile); works and let you know if I find something.

1 like

Please or to participate in this conversation.