QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.28k stars 59 forks source link

Question: Is there feature for use translate outside hook and component? #399

Open bemulima opened 5 months ago

bemulima commented 5 months ago

I would like use translate any where except hooks and components. On i18next I using t :

import { t } from 'i18next';

const anyFunc = () => {
   ...
   const myLocalWord = t('my.key'); // return value in set language
}

Is there any similar feature?

bemulima commented 5 months ago

Срал я на вашу библиотеку!!! Блять TypeScript нихуя у вас не работает!!!! Я сколько убил время на вашу гребанную библиотеку!!! Документация 0! Нет нормальных информаций!!! Блять а я всю интернационализацию сделал на вашей бибиотеке. Столкнулся куча проблемой начиная не могу вызвать вне хука и компонента заканчививая типизацией! Я пишу на русском потому, что не передать эмоцию.

Типизация у вас хуй!

У меня указаны дополнительный параметры image

при вызове ругается image

I don't care if you answer or not! I start migrate to i18next!

gustaveWPM commented 4 months ago

I start migrate to i18next!

Good luck... If you're unhappy with Next International, I would recommend you to give a look to Next Intl, better than i18next...

The error you got on return t is probably due to a minor mistake in your config files which load the locales. This error is very insidious and misleads a lot. In reality, it's a bullshit from TypeScript on an Awaited which is a little messed up, and that could come from there.

Concerning a call to the t function outside a hook... Unfortunately, it doesn't seem possible at the moment. I'm sure it could be done without a heavy refactor of the lib (just by exposing some helpers functions...).

There's nothing blocking you to import the desired locale file yourself and use it.