Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abkrim's avatar
Level 13

Translation Nova Cards

I needs make translatable my cards. But I don't see in manual how to I can made this.

Your Nova card's service provider registers your card's compiled assets so that they will be available to the Nova front-end:

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    $this->app->booted(function () {
        $this->routes();
    });

    Nova::serving(function (ServingNova $event) {
        Nova::script('{{ component }}', __DIR__.'/../dist/js/card.js');
        Nova::style('{{ component }}', __DIR__.'/../dist/css/card.css');
        Nova::translations(__DIR__.'/../resources/lang/en/card.json');
    });
}

Well.

I create un my Card translations tests

nova-components/mycard/resources/lang/es/card.json (and /en)

{
    "Card1": "This is an example in English"
}

nova-components/mycard/resources/js/components/Card.vue

Below get error in console

...
<p class="text-90 leading-normal">
    {{ $t('Card1') }}
</p>

Also I tried, but this saws original text

<p class="text-90 leading-normal">
    __('Card1')
</p>

This usually for me for use in my vue projets (not mixin Laravel & Vue. Full vue)

But not work, because $t is not defined.

I'm lost with documentation.

0 likes
1 reply
abkrim's avatar
Level 13

Oh my God... very hard a doc os Laravel Nova.

Solution is more simple

<p class="text-90 leading-normal">
    {{ __('Card1') }}
</p>

Please or to participate in this conversation.