- How do I generate missing locales for my Laravel app using this package?
- Run `vendor/bin/lang create` without arguments to generate all missing locales, or specify a locale with `--locale=es` to create just one. The tool scans your app for existing translations and creates empty files for unsupported languages in your `resources/lang` directory.
- Can I download translations directly from Laravel/framework or Jetstream using this package?
- Yes. Use `vendor/bin/lang download --url=[ZIP_URL] --project=framework --ver=9.x` to fetch translations from Laravel’s official repositories. The package supports Laravel, Jetstream, and custom URLs, with version-specific metadata to ensure compatibility.
- What Laravel versions does this package support?
- The package is fully compatible with Laravel 8.x through 13.x. It abstracts version-specific localization changes (e.g., `trans_choice` support) internally, so you don’t need to adjust your code when upgrading within this range.
- How do I copy translations to a custom path instead of the default `resources/lang`?
- Use the `--copy` flag to specify paths, like `--copy=lang --copy=custom/path`. For example, `vendor/bin/lang download --url=[URL] --copy=app/locales` will mirror files to `app/locales` instead of the default directory.
- Does this package work with Google Translate API for auto-translation?
- Yes, the `lang translate` command integrates with Google Cloud Translate to auto-generate translations. You’ll need a Google API key, but be aware of usage costs—this is best for drafts or low-priority keys before human review.
- Can I use this in CI/CD to validate translation coverage?
- Absolutely. Run `vendor/bin/lang status` to generate a machine-readable report of missing translations. Integrate this into your pipeline (e.g., GitHub Actions) to enforce minimum coverage thresholds or block merges if translations fall below a set percentage.
- What happens if I run `lang download` with `--only-copy`?
- The `--only-copy` flag skips key-level validation and simply mirrors files from the source to your specified paths. This is useful for bulk syncs where you trust the source files (e.g., copying entire `lang` directories) without checking for missing keys.
- Are there alternatives to Google Translate for auto-translation?
- The package doesn’t natively support alternatives like DeepL or LibreTranslate, but you can extend it by modifying the `TranslateService` or using a wrapper around your preferred API. The core CLI commands remain agnostic to the translation provider.
- How do I handle conflicts when syncing translations from upstream (e.g., Laravel/framework) into my custom codebase?
- The package doesn’t merge files automatically to avoid overwriting custom translations. Use `--only-copy` to mirror files, then manually resolve conflicts. For automated workflows, consider pre-processing files or using a diff tool to highlight changes before applying updates.
- What should I do if the package fails to parse a translation file (e.g., corrupted JSON)?
- Check the error logs for the specific file and path. You can skip problematic files by using `--only-copy` or manually validate the source before downloading. For production, wrap the command in a try-catch block or use a CI step to pre-validate files.