Overview
Nova may be fully localized using Laravel’s localization services. After running thenova:install
command during installation. Your application will contain a lang/vendor/nova
translation directory.
Within this directory, you may customize the en.json
file or create a new JSON translation file for your language. In addition, the en
directory contains a few additional validation translation lines that are utilized by Nova.
Creating New Localization Files
To quickly create a new translation file for your language, you may execute thenova:translate
Artisan command. This command will simply copy the default en.json
translation file, allowing you to begin translating the strings into your own language:
User Locale Overrides
Laravel Nova frontend libraries, including the browser, Numbro.js, Luxon, and other libraries will utilize the locale value available viaapp()->getLocale()
by default. However, if your application is only using ISO 639-1 language codes (en
), you may wish to consider migrating your languages to IETF language tags (en-US
, en-GB
) for wider support across the various frontend libraries used by Nova.
To map your existing locales to IETF language tags, you may use the Nova::userLocale
method. Typically, you should invoke this method in the boot
method of your application’s NovaServiceProvider
:
app/Providers/NovaServiceProvider.php
Resources
Resource names may be localized by overriding thelabel
and singularLabel
methods on the resource class:
app/Nova/~Resource.php
createButtonLabel
and updateButtonLabel
methods on the resource:
app/Nova/~Resource.php
Fields
Field names may be localized when you attach the field to your resource. The first argument to all fields is its display name, which you may customize. For example, you might localize the title of an email address field like so:Relationships
Relationship field names may be customized by localizing the first argument passed to their field definition. The second and third arguments to Nova relationship fields are the relationship method name and the related Nova resource, respectively:label
and singularLabel
methods on the related resource:
app/Nova/~Resource.php
Filters
Filter names may be localized by overriding thename
method on the filter class:
app/Nova/Filters/~Filter.php
Lenses
Lens names may be localized by overriding thename
method on the lens class:
app/Nova/Lenses/~Lens.php
Actions
Action names may be localized by overriding thename
method on the action class:
app/Nova/Actions/~Action.php
Metrics
Metric names may be localized by overriding thename
method on the metric class:
app/Nova/Metrics/~Metric.php
Frontend
To propagate your localizations to the frontend, you should call theNova::translations
method within your NovaServiceProvider
:
app/Providers/NovaServiceProvider.php
app/Providers/NovaServiceProvider.php
__
helper within your custom Vue components to access these translations. To accomplish this, add the following mixins to your Inertia page component or Vue component: