Next.js Discord

Discord Forum

useTranslation outside next-intl context, is it possible ?

Unanswered
Savannah posted this in #help-forum
Open in Discord
SavannahOP
Hey, i want to put my offers into a config file as an exportable function to use her in other files (outside next-intl context), but i can't use the function useTranslation to set labels to my offers, anyone have an idea on how i can do that ? Thanks for your answers 😉

The variable i want to export and put in a config file :

    const subscriptionPlans: SubscriptionPlan[] = [
        {
            name: 'basic',
            title: offers_t('Basic_Plan.Title'),
            desc: offers_t('Basic_Plan.Description'),
            monthlyPrice: 19.99,
            yearlyPrice: 169.99,
            stripePriceId: type === 'monthly' ? PUBLIC_STRIPE_BASIC_PRICE_ID_MONTHLY : PUBLIC_STRIPE_BASIC_PRICE_ID_YEARLY,
            features: [
                offers_t('Basic_Plan.Features.1'),
                offers_t('Basic_Plan.Features.2'),
                offers_t('Basic_Plan.Features.3'),
            ]
        },
        {
            name: 'society',
            title: offers_t('Society_Plan.Title'),
            desc: offers_t('Society_Plan.Description'),
            monthlyPrice: 29.99,
            yearlyPrice: 319.99,
            stripePriceId: type === 'monthly' ? PUBLIC_STRIPE_SOCIETY_PRICE_ID_MONTHLY : PUBLIC_STRIPE_SOCIETY_PRICE_ID_YEARLY,
            features: [
                offers_t('Society_Plan.Features.1'),
                offers_t('Society_Plan.Features.2'),
                offers_t('Society_Plan.Features.3'),
                offers_t('Society_Plan.Features.4'),
                offers_t('Society_Plan.Features.5'),
            ]
        }
    ];

0 Replies