Download the PHP package sematico/laravel-inertia-i18n without Composer

On this page you can find all versions of the php package sematico/laravel-inertia-i18n. 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-inertia-i18n

Laravel Inertia i18n

Packagist Version npm version CI

Share Laravel JSON translations with an Inertia.js React application. The Composer package loads locale files and exposes them as Inertia props; the React package provides translation hooks and component interpolation.

Package Install from
sematico/laravel-inertia-i18n Packagist
@sematico/laravel-inertia-i18n-react npm

[!NOTE] The React package reads an i18n prop shared by the Laravel service provider. Keep <I18nProvider> inside your Inertia app tree.

Requirements

Installation

Install the backend package:

The service provider registers itself through Laravel package discovery. Publish the configuration file only when you need to change its defaults:

Install the React package:

Backend setup

Create JSON files in Laravel's lang directory. The file name is the locale:

By default, the package shares this payload as page.props.i18n:

For locale switching, add the middleware to the routes that should accept the _locale query parameter:

HandleLocale validates locale names and stores an accepted locale in the session. Set supported_locales in the config file to restrict the accepted list.

React setup

Mount the provider once around the part of the tree that uses translations:

Use t, read the active locale, or request a locale reload:

t() supports Laravel-style plural forms and interpolation:

Use Trans when translated text contains named component tags:

Configuration

The published config/inertia-i18n.php file supports:

Option Default Purpose
auto_share true Share translations through the service provider
prop_name i18n Name of the Inertia prop
lang_path null Custom directory containing {locale}.json files
supported_locales null Optional allow-list for HandleLocale

Set auto_share to false when you want to call translationProps() from the SharesTranslations trait in your own Inertia middleware. If prop_name is changed, pass the same value to <I18nProvider propName="translations">.

Public API

Development

The package build writes distributable files to packages/react/dist. The published npm package contains that build output plus the project README and license file.

License

This package is open-sourced software licensed under the MIT license.


All versions of laravel-inertia-i18n with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
inertiajs/inertia-laravel Version ^3.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 sematico/laravel-inertia-i18n contains the following files

Loading the files please wait ...