Download the PHP package in10/multilanguage without Composer

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

IN10 Multilanguage

Simple, opinionated multilanguage package for Laravel

Contents

Requirements

Design

This is an opinionated package: it works in a specific way, based on the setups we run at IN10. That means:

  1. All translated routes start with a route part, e.g. example.com/de/news/
  2. A website has a pre-defined set of languages, all other languages return a 404.
  3. A language is always two characters.
  4. The homepage is translated.
  5. The website has a single default language, by default "en" which you can change in the configuration. This default language is excluded from the URL via a 301-redirect. If you visit example.com/en/test, it will be redirected to example.com/test.

Installation

Install the package using composer:

and publish the configuration file:

You can customize this file as needed.

Migrating from ARCANEDEV/localization

One of the packages we used to use at IN10 is ARCANEDEV/Localization. To facilitate an easy upgrade from the package to this new, smaller package, execute the following steps:

  1. Remove the existing package: composer remove arcanedev/localization.
  2. Remove the ServiceProvider and configuration file if needed.
  3. Follow the steps in the Installation section above to install IN10/multilanguage.
  4. Search through your project for the following instances of Localization-specific code that must be replaced
Search for Replace with Remarks
localization()->getCurrentLocale() App::getLocale() Don't forget to import the Facade
Localization::getCurrentLocale() App::getLocale() Don't forget to import the Facade
config('localization.supported-locales') config('languages.supported-languages
  1. Test your project thoroughly to check if all translated routes and features still work.

Usage

Setting up groups

You can make a set of routes translated by wrapping them in a group:

The first parameter attributes takes the same settings as a regular route group, except for prefix, as and middleware, which are overwritten (these parameters are required to make the translation work). The multilanguage-group should be a root-level construct. Adding it inside of another group or prefix is not tested and probably won't work.

Route translation

In some cases, you might want to translate slugs in the URL. A common example is the /en/news/an-article and /nl/nieuws/een-artikel variants of URLs. This can be accomplished using the transGet routing function:

Note that using transGet outside of a multilanguage routing group will not work.

The translation key is automatically looked up in the routes.php translation file. All translation routes must always be translated. Don't fret: the package will scream at you if you're missing a translation.

Route generation

If you want to generate a route with a correct language, use the included helper:

This helpers takes the same parameters as the Laravel route() helper, with an optional language as a last parameter. If you omit the language, the helper uses the current language for the request. This is usually what you want, so in general you can use the translatedRoute helper as if it were the regular helper:

which will generate /nl/news/five-ways-to-translate-content in this example if the current language is set to Dutch.

Developer

Jakob Buis

License

Copyright 2019 IN10. All rights reserved.


All versions of multilanguage with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ^7.2 || ^7.3 || ^7.4
laravel/framework Version ^8.0.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 in10/multilanguage contains the following files

Loading the files please wait ....