All Projects โ†’ keevitaja โ†’ Linguist

keevitaja / Linguist

Licence: mit
Easy multilingual urls and redirection support for the Laravel framework

Projects that are alternatives of or similar to Linguist

Localization
๐ŸŒ Localization package for Laravel
Stars: โœญ 142 (-24.47%)
Mutual labels:  laravel, localization, multilingual
I18n Extract
Manage localization with static analysis. ๐Ÿ”
Stars: โœญ 152 (-19.15%)
Mutual labels:  translation, i18n, localization
Pseudo Localization
Dynamic pseudo-localization in the browser and nodejs
Stars: โœญ 109 (-42.02%)
Mutual labels:  translation, i18n, localization
Punic
PHP translation and localization made easy!
Stars: โœญ 133 (-29.26%)
Mutual labels:  translation, i18n, localization
Formatjs
The monorepo home to all of the FormatJS related libraries, most notably react-intl.
Stars: โœญ 12,869 (+6745.21%)
Mutual labels:  translation, i18n, localization
Laravel Lang
๐ŸŒ 75 languages support for Laravel application.
Stars: โœญ 1,134 (+503.19%)
Mutual labels:  i18n, laravel, localization
Deeply
PHP client for the DeepL.com translation API (unofficial)
Stars: โœญ 152 (-19.15%)
Mutual labels:  translation, i18n, laravel
Localization Helper
๐ŸŽŒ Laravel Localization Helper :: Easily add translation variables from Blade templates.
Stars: โœญ 31 (-83.51%)
Mutual labels:  translation, laravel, localization
Es2015 I18n Tag
ES2015 template literal tag for i18n and l10n (translation and internationalization)
Stars: โœญ 171 (-9.04%)
Mutual labels:  translation, i18n, localization
React I18nify
Simple i18n translation and localization components and helpers for React.
Stars: โœญ 123 (-34.57%)
Mutual labels:  translation, i18n, localization
React Intl Hooks
React hooks for internationalization without the hassle โš›๏ธ๐ŸŒ
Stars: โœญ 64 (-65.96%)
Mutual labels:  translation, i18n, localization
React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project ๐ŸŒŽ๐ŸŒ๐ŸŒ
Stars: โœญ 176 (-6.38%)
Mutual labels:  translation, i18n, localization
Atom I18n
:atom: One Atom i18n Package for Any Locale ๐ŸŒ ๐ŸŒŽ ๐ŸŒ
Stars: โœญ 56 (-70.21%)
Mutual labels:  translation, i18n, localization
Keys Translations Manager
KTM, a locale management web app built on MERN stack, lets you manage and control locales in one place. It's particularly useful for someone who needs to manage multiple internationalization/localization projects.
Stars: โœญ 81 (-56.91%)
Mutual labels:  i18n, localization, multilingual
Parrot
Self-hosted Localization Management Platform built with Go and Angular
Stars: โœญ 967 (+414.36%)
Mutual labels:  translation, i18n, localization
Traduora
Everยฎ Traduora - Open-Source Translation Management Platform
Stars: โœญ 1,580 (+740.43%)
Mutual labels:  translation, localization, i18n
Mobility
Pluggable Ruby translation framework
Stars: โœญ 644 (+242.55%)
Mutual labels:  translation, i18n, localization
Frenchkiss.js
The blazing fast lightweight internationalization (i18n) module for javascript
Stars: โœญ 776 (+312.77%)
Mutual labels:  translation, i18n, localization
Phabricator zh hans
Phabricator zh-Hans Translation & Tools.
Stars: โœญ 113 (-39.89%)
Mutual labels:  translation, i18n, localization
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: โœญ 125 (-33.51%)
Mutual labels:  translation, i18n, localization

Linguist - Multilingual urls and redirects for Laravel

This package provides an easy multilingual urls and redirection support for the Laravel framework.

In short Laravel will generate localized urls for links and redirections.

route('people') 
http://site.com/people
http://site.com/fr/people

Linguist works perfectly well with https://github.com/tightenco/ziggy named Laravel routes for javascript package!

Installation

Linguist is very easy to use. The locale slug is removed from the REQUEST_URI leaving the developer with the cleanest multilingual environment possible.

Install using Composer:

composer require keevitaja/linguist

There are several options to make Linguist work.

Option 1: Modify the public/index.php

Add following line after the vendor autoloading to your projects public/index.php file.

(new Keevitaja\Linguist\UriFixer)->fixit();

End result would be this:

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';

(new Keevitaja\Linguist\UriFixer)->fixit();

Option 2: Use LocalizedKernel

Note: This option works only if you have not changed your applications root namespace. Default is App.

In your projects bootstrap/app.php swap the App\Http\Kernel with Keevitaja\Linguist\LocalazedKernel:

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    //App\Http\Kernel::class
    Keevitaja\Linguist\LocalizedKernel::class
);

Option 3: modify the App\Http\Kernel

Note: This also works with custom root namespace.

<?php

namespace App\Http;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Routing\Router;
use Keevitaja\Linguist\UriFixer;

class Kernel extends HttpKernel
{

    public function __construct(Application $app, Router $router)
    {
        (new UriFixer)->fixit();

        parent::__construct($app, $router);
    }

Publish config

Finally you need to publish the Linguist config to set your enabled locales and other relavant configurations.

php artisan vendor:publish --provider="Keevitaja\Linguist\LinguistServiceProvider"

Your personal configuration file will be config/linguist.php.

Usage

You can add the LocalizeUrls middleware your web middleware group as the first item to get the linguist support:

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \Keevitaja\Linguist\LocalizeUrls::class,

Note: This middleware has to be the first item in group!

Another option is to use Linguist in your applications service provider:

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(\Keevitaja\Linguist\Linguist $linguist)
    {
        $linguist->localize();
    }

UrlGenerator will add the locale slug in front of the URI when needed. No extra actions needed.

Route::get('people', ['as' => 'people.index', 'uses' => ''PeopleController@index'']);
{{ route('people.index') }} or {{ url('people') }}
http://site.com/people // default locale from linguist config
http://site.com/fr/people
http://site.com/ru/people

Switcher is a little helper to get the current URLs for the locale switcher.

$urls = dispatch_now(new \Keevitaja\Linguist\Switcher);

NB! Both config and route caching are working!

Assets

Use linguist helpers for a correct routing of assets

Regular Assets

<link rel="stylesheet" href="{{ linguist_asset('css/style.css') }}">
<script type="text/javascript" src="{{ linguist_asset('js/my_js.js') }}"></script>

Secure Assets

<link rel="stylesheet" href="{{ secure_linguist_asset('css/style.css') }}">
<script type="text/javascript" src="{{ secure_linguist_asset('js/my_js.js') }}"></script>

Queues

To make localization work in queues you need to run Linguist->localize($theLocaleYouWant) inside the queued item.

Licence

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].