Weave 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

Translate Laravel Package

scafera/translate

Scafera Translate is a Laravel/PHP package for managing multilingual translations with a clean, consistent API. It helps you organize and serve language strings so your application stays localized, maintainable, and easy to scale as your project grows. Designed to fit naturally into Laravel projects...

View on GitHub
Deep Wiki
Context7

Getting Started

At a glance, this release only tightens failure handling around a missing translations directory, so the assessment below is grounded in that behaviour plus standard Laravel translation-package conventions.

  1. composer require <vendor>/<package> and let package discovery register the service provider.
  2. Publish the config (php artisan vendor:publish --tag=<package>-config) — this is the first file to read, since it almost certainly holds the translations path, loader selection, and any cache settings.
  3. Check the service provider's boot()/register() for how it resolves the translation service — that binding is where ServiceNotFoundException originated prior to v1.0.2.
  4. First use case: run php artisan config:clear and hit a page with a missing/extra lang directory to confirm the fix behaves as described (no exception, graceful degradation).

If your app already ships a populated lang/ directory, the upgrade is a drop-in patch with no API surface change.

Implementation Patterns

Directory-agnostic bootstrapping. The v1.0.2 fix implies the package previously assumed the translations directory existed at resolution time. Treat the directory as optional in your own code too:

// config/<package>.php
'path' => env('TRANSLATIONS_PATH', lang_path()),

This keeps local dev, CI, and container builds consistent without relying on the package's new null-safety to paper over a misconfigured path.

Guard in CI rather than at runtime. Because a missing directory now resolves silently instead of throwing, promote the check into a test:

it('ships translation files', function () {
    expect(is_dir(lang_path()))->toBeTrue()
        ->and(glob(lang_path('en/*.php')))->not->toBeEmpty();
});

Per-environment wiring. Local: default lang_path(). Production: a read-only path baked into the image. If you use a DB or remote translation source, bind your custom loader in a dedicated provider registered after the package provider so yours wins.

Deploy pipeline integration. Add the directory (or at least a .gitkeep) to your build artifact and verify it survives docker build — the classic failure is COPY globs that drop empty directories, which is exactly the scenario this patch was written for.

Testing. Point the config at a fixture directory in phpunit.xml via env var, and use config()->set() in setUp() for per-test overrides instead of mutating files on disk.

Gotchas and Tips

  • Silent success is the new failure mode. After v1.0.2, a typo in the translations path no longer raises ServiceNotFoundException; you get empty strings or raw keys in the UI. Watch for untranslated keys in staging — they are the real signal now. Consider asserting __('some.known.key') !== 'some.known.key' in a smoke test.
  • The fix is not a substitute for a valid path. If the package still requires an existing directory for writing (export/cache commands), those paths may have their own guards. Re-test php artisan <package>:cache style commands after upgrading.
  • config:cache freezes the resolved path. If the directory is created later in the boot sequence (e.g. by a deployment script running after artisan optimize), the cached config points at a location that may not exist yet at request time. Clear and rebuild caches as the final deploy step.
  • Case sensitivity. Paths that work on macOS (case-insensitive FS) can fail on Linux runners — a common source of "missing directory" reports that look environment-specific.
  • Cache invalidation. If the package caches loaded translation groups, deleting or adding the directory won't be reflected until you run the package's clear command or flush the application cache.
  • Extension points. Look for a loader interface or a Translator::extend() hook in the provider; that is the supported seam for custom sources. Avoid subclassing the package's service directly — internal bindings are what shifted between 1.0.1 and 1.0.2.
  • Upgrade risk: low. This is a patch-level, additive guard. The only behaviour change is a caught failure path, so pinning ^1.0 is reasonable; there is no migration or republish step indicated.
  • Verify the fix, don't assume it. Temporarily point the config at a non-existent path and confirm the app renders keys rather than a 500 — you want to know whether the failure is truly handled or merely moved further down the stack.
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.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package