Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Common Laravel Package

laravel-lang/common

Shared utilities for the Laravel Lang ecosystem: common helpers, contracts, and tooling used across translation and localization packages. Provides reusable building blocks to keep language resources consistent, maintainable, and easy to integrate into Laravel apps.

View on GitHub
Deep Wiki
Context7

Easily connect the necessary language packs to the application

Frequently asked questions about Common
How do I install `laravel-lang/common` in a Laravel 10+ project?
Run `composer require laravel-lang/common` via Composer. The package integrates automatically with Laravel’s service container and requires no manual configuration for basic usage. Follow the [official documentation](https://laravel-lang.com/packages-common.html) for advanced setups like dynamic language pack sources.
Can this package replace Laravel’s built-in `resources/lang` files entirely?
No, but it supports a hybrid approach. Start by keeping static files as fallbacks while dynamically loading packs from APIs, CDNs, or databases. Use the `config('lang.dynamic_packs.enabled')` flag to enable dynamic packs for specific locales gradually.
Does `laravel-lang/common` support loading translations from a database?
Yes, the package supports database-driven language packs. You’ll need to model translations (e.g., a `translations` table with `locale`, `key`, and `value` columns) and configure the source in your `config/lang.php`. JSON fields or dedicated tables work well.
What happens if a language pack fails to load from an external API/CDN?
The package includes fallback chains—it will attempt to load from the next source (e.g., local cache, default language) if the primary source fails. Configure retry logic and timeouts in your `config/lang.php` under `fallback_strategy` to handle transient failures gracefully.
Is there performance overhead for dynamic language packs, and how can I mitigate it?
Dynamic loading can introduce latency, but the package recommends aggressive caching (e.g., Redis or edge caching like Cloudflare). Set appropriate TTLs in your cache config and monitor translation load times. For critical apps, preload packs during low-traffic periods.
Will this package work with Laravel 9 or older versions?
The package is officially tested on Laravel 10+. For older versions, check for deprecated method calls or missing features (e.g., service container changes). You may need to polyfill or adjust middleware if compatibility issues arise.
Can I customize language pack structures (e.g., nested keys, pluralization rules)?
Yes, the package supports custom structures. Extend the `LanguagePack` contract or override default parsers in your service provider. For pluralization, integrate with libraries like `voku/translation` or leverage Laravel’s built-in `@choice` directive.
How do I migrate existing `resources/lang` files to dynamic packs?
Start with a hybrid setup: keep static files as fallbacks while dynamically loading packs for user-selected languages. Use database migrations to backfill existing translations into your dynamic source (API/CDN/DB). Deprecate static files gradually via middleware or config flags.
Does this package support right-to-left (RTL) languages or custom interpolation?
The package is language-agnostic and supports RTL languages out of the box. For custom interpolation (e.g., context-aware fallbacks like `trans('key', ['context' => 'admin'])`), extend the `Translator` facade or create custom macros in your service provider.
Are there alternatives to `laravel-lang/common` for dynamic translations?
Alternatives include `spatie/laravel-translatable` (for Eloquent models) or `laravel-localization` (for route/localization helpers). However, `laravel-lang/common` uniquely focuses on reusable tooling for dynamic packs (API/CDN/DB) while maintaining compatibility with Laravel’s core localization system.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php