abkrim
3 months ago
460
1
Nova

Translation Nova Cards

Posted 3 months ago by abkrim

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.

Please sign in or create an account to participate in this conversation.