lokalise / i18n-ally

🌍 All in one i18n extension for VS Code
https://marketplace.visualstudio.com/items?itemName=lokalise.i18n-ally
MIT License
3.91k stars 309 forks source link

There is a mismatch in next-i18next #996

Open JerryFan626 opened 1 year ago

JerryFan626 commented 1 year ago

Describe the bug There is a mismatch in next-i18next

Extension Version i18n Ally v2.11.0

Framework/i18n package you are using next-i18next

To Reproduce

// vscode/setting.json
{
  "i18n-ally.localesPaths": "public/locales",
  "i18n-ally.keystyle": "nested"
}
import { GetStaticPaths } from 'next';
import { useTranslation } from 'next-i18next';
import { getLocaleProps } from '@/utils/locale';

export const getStaticProps = getLocaleProps(['home', 'common']);

function Home() {
  const { t } = useTranslation('home');

  // An error occurs here, and it keeps saying that home.nav.home was not found
  return <div>{t('nav.home')}</div>;
}

export default Home;

Device Infomation

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

Screenshots

terales commented 1 year ago

@aranard @chazeah this looks like a regression related to https://github.com/lokalise/i18n-ally/pull/926

Can you look into it, please?

aranard commented 1 year ago

Hi @terales, what makes you think this is related to https://github.com/lokalise/i18n-ally/pull/926? I'm not seeing anything in the bug report that shows an immediate connection. Were you able to reproduce and found more information?

aranard commented 1 year ago

Investigating this further, I still don't see a connection to my change. https://github.com/lokalise/i18n-ally/pull/926 was an enhancement only to the "custom" framework, which the configuration in this issue does not appear to be using.

The release also included this change https://github.com/lokalise/i18n-ally/pull/941, which modified editor and core key detection code. This seems more likely related. If there's something I'm missing, let me know and I can continue to look into it.

terales commented 1 year ago

Thank you for the research and sorry for the wrong attribution, @aranard!

@Angeart, can you look into this issue as it seems to be a regression related to #941, please?

Angeart commented 1 year ago

@terales @fanjinyu-fjy I think it's not related. You might want to have to just turn on "i18n-ally.namespace": true on setting.json.

I checked working with below settings.

{
  "i18n-ally.enabledFrameworks": [
    "react-i18next"
  ],
  "i18n-ally.namespace": true,
  "i18n-ally.keystyle": "nested",
  }

public/
├─ locales/
│  ├─ en/
│  │  ├─ common.json
│  │  ├─ foo.json

image