vue.jslaravel-bladelaravel-sparklaravel-localization

Translate Laravel Spark plan features


I was wondering what would be the best way to display my Spark plan features in multiple different languages.

Let's say I have the followings features

Spark::plan('Premium', 'monthly-artist-premium')
        ->price(10)
        ->trialDays(14)
        ->features([
            'Online profile', 'Access To More Features',
        ]);

I thought about doing something like this using Laravel's translation tool and the translation keys

Spark::plan('Premium', 'monthly-premium')
        ->price(10)
        ->trialDays(14)
        ->features([
            'base.Online_profile', 'base.Access_to_more_features',
        ]);

And then when rendering the plans using Vue I would do something like this, but it's not translating.

<li class='pricing-feature' v-for="feature in plan.features">
    @lang('@{{ feature }}')
</li>

Any idea how I could implement this to handle multiple languages?


Solution

  • Not the best solution, but here's what I ended up doing:

    Spark::freePlan('Basic')
            ->features([
                'free_plan'
    ]);
    

    Then when showing the plans in register-common.blade.php

    I did something like this with the v-if conditions for each different plans

    <ul v-if="plan.features[0] === 'free_plan'" class='pricing-feature-list'>
        <li class="pricing-feature">
            @lang('base.Online_profile')
        </li>
    </ul>