小编Hay*_*yan的帖子

如何在 getStaticProps Next.js 中访问当前语言?

我在下一个应用程序中使用 i18n,我需要在 getStaticProps 中访问当前页面语言,然后获取数据

export const getStaticProps = async () => {
  //need to get language here

  return {
    props: { data },
  };
};

const App = ({ data }) => {
  //my component where i can get language

  const { t, i18n } = useTranslation();

  const currentLang = i18n.language;
};
Run Code Online (Sandbox Code Playgroud)

i18next reactjs next.js

3
推荐指数
1
解决办法
5124
查看次数

标签 统计

i18next ×1

next.js ×1

reactjs ×1