- How do I install `laravel-lang/native-country-names` in a Laravel project?
- Run `composer require laravel-lang/native-country-names` in your project root. The package auto-registers via Laravel’s service provider system, so no additional configuration is needed unless you want to customize the default locale behavior.
- Does this package support Laravel 13’s new app contexts or locale detection?
- Yes, the package is fully compatible with Laravel 13 and leverages the framework’s built-in locale detection (`app()->getLocale()`). For dynamic contexts, use `Country::setLocale($locale)` to override the default or pass a locale directly to `Country::name($code, $locale)`.
- Can I use this for country dropdowns in a multi-language admin panel?
- Absolutely. The package integrates natively with Blade templates—just use `{{ Country::name('US', app()->getLocale()) }}` in your dropdown options. For frontend frameworks like Vue or React, expose the data via an API endpoint (e.g., `Country::all()`) or bundle it with Laravel Mix.
- What happens if a country name isn’t available in the user’s preferred locale?
- The package defaults to English (`en`) if the requested locale lacks a translation. You can customize this by extending the dataset via `Country::extend()` or setting a fallback locale globally in the service provider. The fallback behavior is configurable.
- Is there a performance impact for high-traffic sites (e.g., e-commerce checkouts)?
- No. The package loads country names from static JSON files (~50KB) and caches responses automatically. For critical endpoints, manually cache `Country::all()` or `Country::name()` calls using Laravel’s cache drivers (e.g., Redis) to reduce overhead.
- How do I handle country names that differ by region (e.g., 'Korea' vs. 'Republic of Korea')?
- The package uses ISO 3166-1 compliant datasets, which include regionally preferred names (e.g., '대한민국' for South Korea in Korean). For exceptions, override specific entries via `Country::extend(['KR' => ['ko' => '대한민국']])` or fork the package to customize the dataset.
- Can I use this package in a headless Laravel API for a React/Vue frontend?
- Yes. The package returns structured JSON (e.g., `{ code: 'US', name: 'United States' }`) when called via APIs. Expose endpoints like `route('api.countries')` with `Country::all()` or `Country::name($code, $locale)` to serve localized data to your frontend.
- Are there alternatives if I need country flags, subdivisions, or additional metadata?
- This package focuses solely on native country names. For flags or subdivisions (e.g., states/provinces), consider supplementing with `league/iso3166` or `spatie/laravel-country` (which includes flags). The MIT license allows forking to combine datasets if needed.
- How often are the country name datasets updated, and how can I contribute?
- Datasets are updated via GitHub Actions and validated against ISO standards. Contributions are welcome—submit PRs to the [GitHub repo](https://github.com/Laravel-Lang/native-country-names) or report missing translations. The Laravel Lang team monitors updates closely for breaking changes.
- Does this package work with Laravel’s localization tools like Crowdin or Lokalise?
- Yes, but with a caveat: the package’s datasets are static JSON files. For dynamic syncs, export your Crowdin/Lokalise translations to a compatible format and merge them into the package’s `resources/lang` directory. Automate this via CI/CD pipelines to keep datasets in sync.