Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract command detects but doesn't add new translation keys to JSON files #65

Open
Heet-Bhalodiya opened this issue Jan 20, 2025 · 0 comments

Comments

@Heet-Bhalodiya
Copy link

The languine extract command successfully detects new translation keys in the codebase but doesn't automatically add them to the translation JSON files. This seems to be different from the expected behavior of an extraction tool.

Current Behavior

  1. The extract command finds new translation keys (shows "Found X new translation keys")
  2. However, these keys are not added to the translation files
  3. We need to manually add the keys to the English translation file first

Expected Behavior

  1. When new translation keys are found in the code
  2. They should be automatically added to the English translation file
  3. Then the translate command can generate translations for other languages

Reproduction Steps

  1. Start with this translation file (en/translation.json):
{
  "welcome": "Welcome to Next.js",
  "landing": {
    "reviews": {
      "title": {
        "real": "Real",
        "customers": "Customers Reviews"
      }
    }
  }
}
  1. Add a new translation key in a component:
import { useTranslation } from 'react-i18next'

const Component = () => {
  const { t } = useTranslation()

  // New translation key that doesn't exist in JSON
  console.log(t('test.extract.key'))

  return (
    // ... rest of the component
  )
}
  1. Run the extract command:
npx languine extract
  1. Result:
┌  Extracting translation keys...
│
└  Found X new translation keys from source files
  1. Check en/translation.json - the new key test.extract.key is not added

Environment

  • Languine Version: 1.0.2
  • Node.js Version: v22.12.0
  • OS: macOS 24.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant