PHP code example of michele-angioni / multi-language

1. Go to this page and download the library: Download michele-angioni/multi-language library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

michele-angioni / multi-language example snippets


MicheleAngioni\MultiLanguage\MultiLanguageServiceProvider:class,
MicheleAngioni\MultiLanguage\MultiLanguageBindServiceProvider:class

/app
├--/controllers
├--/lang
|     └--/en
|          └--users.php



return array(

    "password" => "Passwords must be at least six characters and match the confirmation.",

    "user" => "We can't find a user with that e-mail address.",

    "token" => "This password reset token is invalid.",

    "sent" => "Password reminder sent!",

);



use MicheleAngioni\MultiLanguage\LanguageManager;

class LanguagesController extends \BaseController {

    private $languageManager;

    function __construct(LanguageManager $languageManager)
    {
        $this->languageManager = $languageManager;
    }

}

public function index()
{
    $languages = $this->languageManager->getAvailableLanguages(); // ['en']

    return View::make('languages')->with('languages', $languages)
}

public function showFiles()
{
    $files = $this->languageManager->getLanguageFiles(); // ['users']

    return View::make('languagesFiles')->with('files', $files)
}

// $fileName = 'users';
public function showFile($fileName)
{
    $file = $this->languageManager->getLanguageFile($fileName)

    return View::make('languagesFile')->with('file', $file)
}

public function createNewLanguage()
{
    // [...] Input validation

    $this->languageManager->createNewLanguage($input['locale']);

    return Redirect::route('[...]')->with('ok', 'New language successfully created.');
}

public function saveFile($locale, $fileName)
{
    // [...] Input validation

    $this->languageManager->setLocale($languageCode);

    $this->languageManager->writeLanguageFile($fileName, $input['all']);

    return Redirect::route('[...]')->with('ok', 'Lang file successfully saved.');
}