Download the PHP package thinktomorrow/locale without Composer

On this page you can find all versions of the php package thinktomorrow/locale. 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 locale

locale

Latest Version on Packagist Quality Score Total Downloads

Requirements

The package requires a php version of 8.2 or more. Laravel version 5.6.* and upwards is supported.

Installation

The package can be installed via Composer.

The package service provider will be autodiscovered by laravel.

To publish the config file to /config/thinktomorrow/locale.php, run:

These are the config defaults:

Setup

Let's say you want to support two locales: nl and en, where nl is the default locale. Here's how you would configure this:

Some important things to note here:

Segments

The package allows for two ways to identify the locale in a request url. Either via path segments or via the host. Let's take a moment to introduce these concepts. A locale segment is the uri path identifier of a specific locale. E.g. example.com/nl has nl as a locale segment since it identifies the locale in the given request uri.. This is the most common way of determining locales via the incoming request. This is also sufficient when your application only has to deal with one domain root.

The configuration for this is the most basic setup where you give a list of locales under the default scope, like the config example from above.

Scopes

A scope is a higher level identifier for a group of locales. Generally, you can compare a scope with the host part of the request url. A scope bundles one or more of these segments together.

Let's say we want to allow example.com and fr.example.com, where the first host localises in nl and the latter in fr. We can provide the following configuration:

If your application is visitable by only one domain root, which is the case for most apps, you are good to go with the default scope. All available application locales are grouped by so called scopes. Each scope has its own set

Usage

To make your routes localized, place them inside a Route::group() with a following prefix:

Generating a localized url

Localisation of your routes is done automatically when named routes are being used. Creation of all named routes will be localized based on current locale. Quick non-obtrusive integration.

To create an url with a specific locale other than the active one, you can use the Thinktomorrow\Locale\LocaleUrl class.

Note: Passing the locale as 'lang' query parameter will force the locale example.com/en/about?lang=nl makes sure the request will deal with a 'nl' locale.

Configuration

Locale API

Set a new locale for current request

Get the current locale

Get the locale slug to be used for url injection

Check if current locale is hidden

Testing

For more details check out our full documentation https://thinktomorrow.github.io/package-docs/src/locale/

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of locale with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
laravel/framework Version ^11.31
thinktomorrow/url Version ^4.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 thinktomorrow/locale contains the following files

Loading the files please wait ....