Download the PHP package niels-numbers/laravel-localizer without Composer

On this page you can find all versions of the php package niels-numbers/laravel-localizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-localizer

Laravel Localizer

Tests PHP Laravel License

Laravel can already prefix routes with /{locale}. What it does not do: detect a visitor's language, redirect them there, remember the choice, and keep route('about') returning the right URL. This package adds exactly that.

Documentation: localizer.adam-nielsen.de

Successor to mcamara/laravel-localization. Coming from there? See the migration guide.

What you get

Wrap your routes once:

The page is now reachable in every configured language:

URL Language
/about en (default, prefix hidden)
/de/about de
/fr/about fr

The default language has no prefix because hide_default_locale is on by default. Turn it off and every URL carries a prefix: /about then redirects to /en/about.

route('about') keeps working as before and returns the URL for the current language: in Blade, controllers, jobs, mails and, with the JavaScript route helpers, in your Vue or React frontend.

Want /de/ueber and /fr/a-propos instead of /de/about? See Translated URL Paths.

What happens on a visit

  1. First visit: someone opens /about. The package reads their browser language (or your own detectors) and redirects them, for example to /de/about. English visitors stay on /about.
  2. From then on the URL decides: /de/about shows German and remembers it in session and cookie. A link to plain /about sends that visitor back to /de/about.
  3. One canonical URL per page: the default language has no prefix, so /en/about redirects to /about.

A language switcher is one helper call per language: Route::localizedSwitcherUrl('fr'). See Language Switcher.

Install

Then set your locales, register two middlewares and wrap your routes. The setup guide walks through the three steps.

Coming from mcamara/laravel-localization?

Same job, different wiring. Every localized route is a plain, static Laravel route, so php artisan route:cache works, translated routes switch reliably and Livewire works out of the box. The migration guide covers the differences step by step.

Not sure you need this package at all? See when to use it and how it compares to mcamara/laravel-localization, codezero-be/laravel-localized-routes and spatie/laravel-translatable.

License & credits

MIT licensed. Created by Adam Nielsen, building on prior work by @mcamara (original laravel-localization), @codezero-be (deprecated laravel-localized-routes, whose static-route ideas inspired this rewrite) and @jordyvanderhaegen (current maintainer of the original, whose issue #921 motivated this package).


All versions of laravel-localizer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
codezero/browser-locale Version ^3.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package niels-numbers/laravel-localizer contains the following files

Loading the files please wait ...