定制 rdcstarr/laravel-locale 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rdcstarr/laravel-locale

Composer 安装命令:

composer require rdcstarr/laravel-locale

包简介

Database-driven language and country management for Laravel.

README 文档

README

Database-driven language and country management for Laravel 13.

  • Languages — ISO 639-1, enabled/default flags
  • Countries — ISO 3166-1 alpha-2, flag emoji, timezone, E.164 calling code, primary language
  • Octane-safe — stateless singleton service, current locale read dynamically per request

Requirements

Dependency Version
PHP ^8.3
Laravel ^13.0

Installation

composer require rdcstarr/laravel-locale

Run the install command to publish and run migrations, then seed languages, countries and their relationships:

php artisan locale:install

Manual installation

If you prefer to control the process yourself, publish the migrations without running the install command:

php artisan vendor:publish --tag=laravel-locale-migrations

Then run the migrations and seed the reference data:

php artisan migrate
php artisan db:seed --class="Rdcstarr\Locale\Database\Seeders\LanguagesSeeder"
php artisan db:seed --class="Rdcstarr\Locale\Database\Seeders\CountriesSeeder"
php artisan db:seed --class="Rdcstarr\Locale\Database\Seeders\CountryLanguageSeeder"

Note: Migrations run automatically without publishing — skip vendor:publish if you do not need to modify the migration files.

Languages

use Locale;

// All enabled languages
Locale::enabledLanguages();

// Default language
Locale::defaultLanguage();

// Find by ISO 639-1 code
Locale::languageByCode('ro');

// code → id map (useful for seeding)
Locale::enabledLanguageCodeToId();

// Raw query builder
Locale::languages()->where('enabled', true)->get();

Countries

use Locale;

// Find by ISO 3166-1 alpha-2 code
Locale::countryByCode('RO');

// Phone prefix (ITU-T E.164, e.g. "+40")
Locale::callingCodeByCode('RO');     // → "+40"
country_calling_code('RO');          // → "+40"  (global helper)
Locale::countryByCode('RO')->calling_code;  // direct model access

// All countries sharing a calling code (e.g. NANP "+1")
Locale::countries()->byCallingCode('+1')->get();

// All countries that use a given language
Locale::countriesForLanguage('ro');

// code → id map (useful for seeding)
Locale::countryCodeToId();

// Raw query builder
Locale::countries()->with('primaryLanguage')->get();

Models

Language

Column Type Notes
id bigint
name string e.g. Romanian
code string(5) ISO 639-1, e.g. ro
enabled boolean default true
default boolean default false

Country

Column Type Notes
id bigint
name string e.g. Romania
code string(2) ISO 3166-1 alpha-2, e.g. RO
flag string URL or path
flag_emoji string e.g. 🇷🇴
timezone string e.g. Europe/Bucharest
calling_code string(10) ITU-T E.164, e.g. +40, +1
primary_language_id FK → languages

The country_language pivot table stores all official languages per country with an is_official boolean.

Octane compatibility

LocaleService is registered as a singleton but stores no request-scoped state — the current locale is always read dynamically via app()->getLocale(), so it is safe to reuse across requests on a long-lived worker.

rdcstarr/laravel-locale 适用场景与选型建议

rdcstarr/laravel-locale 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「i18n」 「locale」 「language」 「l10n」 「laravel」 「country」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rdcstarr/laravel-locale 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rdcstarr/laravel-locale 我们能提供哪些服务?
定制开发 / 二次开发

基于 rdcstarr/laravel-locale 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-18