laravel-lang/native-locale-names
Laravel package providing native-language names for locales. Useful for language pickers and localized UI labels, with simple installation and integration via Laravel Lang documentation. MIT licensed.
App::getLocale(), trans() helpers). Fits cleanly into existing i18n architectures without disrupting core logic.laravel-lang/locale-list (v2+), ensuring consistency with other Laravel-Lang packages (e.g., laravel-lang/locale). Reduces fragmentation in multilingual stacks.['en' => 'English'] → LocaleNames::get('en')).@lang('locale.names.en')) or API responses.en-US vs. en-GB).LaravelLang\NativeLocaleNames\NativeLocaleNamesServiceProvider), enabling dependency injection:
use LaravelLang\NativeLocaleNames\LocaleNames;
public function __construct(LocaleNames $localeNames) { ... }
@nativeLocaleName('en') for templates, reducing boilerplate.| Risk Area | Assessment | Mitigation |
|---|---|---|
| Laravel Version Lock | Supports Laravel 11–13; risk if upgrading beyond v13 (check release notes). | Monitor Laravel-Lang’s roadmap or fork the package if unsupported. |
| Locale Coverage Gaps | Relies on CLDR; rare locales (e.g., constructed languages like "Tok Pisin") may lack entries. | Fallback to locale-list codes or supplement with custom JSON. |
| Performance Overhead | Minimal (~1MB JSON payload); risk if loading all locales upfront in high-traffic APIs. | Lazy-load locales or use LocaleNames::get('locale') on-demand. |
| Data Freshness | Updates via GitHub Actions (e.g., #56); delay between CLDR updates and package releases (~1–3 months). | Subscribe to CLDR announcements or trigger manual updates via composer update. |
| Namespace Conflicts | Uses LaravelLang\NativeLocaleNames; risk if another package uses the same namespace. |
Check composer.json dependencies or alias the class (e.g., use NativeLocaleNames as LocaleNames). |
| Testing Complexity | Locale-specific tests (e.g., RTL scripts) may require additional CI configurations (e.g., ChromeHeadless for rendering checks). | Add a phpunit.xml snippet for locale-aware tests or use Laravel’s built-in localization test helpers. |
Locale Prioritization:
pt-BR vs. pt-PT) that require special handling?Display Context:
Fallback Strategy:
xx-YY) be handled? (Fallback to locale code? Custom mapping?)LocaleNames::get('xx-YY', 'xx-YY') or a LocaleNames::fallback() method.Performance:
Accept-Language-aware locale names?Compliance:
Extensibility:
app-internal)?CI/CD Impact:
composer update be gated? (Automated for minor updates, manual for major versions?)Deprecation:
en_US → en-US)?Native → LocaleNames) be handled?App::setLocale(), trans(), config('app.locale')). Works alongside:
laravel-lang/locale-list, laravel-lang/locale.@nativeLocaleName('locale') directive.Content-Language: zh-CN).^2.0 (for platform-check and prefer-stable).i18next or vue-i18n for client-side rendering.getStaticProps.| Phase | Action Items | Dependencies | Risks | Validation |
|---|---|---|---|---|
| Assessment | Audit current locale names (hardcoded arrays, JSON files, or API calls). Identify gaps (e.g., missing RTL scripts, regional variants). | - Existing config/app.php or resources/lang/ files. |
Underestimating custom locale logic (e.g., en_US vs. en-US). |
Run grep -r "en_US|locale.*name" . in codebase. |
| Setup | Install package: composer require laravel-lang/native-locale-names. Publish config: php artisan vendor:publish --provider="LaravelLang\NativeLocaleNames\NativeLocaleNamesServiceProvider". |
- Laravel 11+. | Config file conflicts (e.g., config/locale.php). |
Check config/locale.php for existing native_locale_names key. |
| Core Integration | Replace hardcoded locale names with LocaleNames::get('locale') or @nativeLocaleName('locale') in Blade. Example: |
- Blade templates. | Breaking changes in template syntax (e.g., @lang vs. @nativeLocaleName). |
How can I help you explore Laravel packages today?