1. Go to this page and download the library: Download gentor/polyglot 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/ */
gentor / polyglot example snippets
class Article extends Model
{
use Polyglot\Polyglot;
protected $polyglot = ['title', 'content'];
}
// Get an automatically localized Article
$article = Article::find(4)
echo $article->fr->title // This will print out the french title
echo $article->title // This will print out the title in the current language
$article->fill([
'title' => 'Titre',
'content' => 'Contenu',
'lang' => 'fr',
])->save();
// Is the same as
$article->fr->fill([
'title' => 'Titre',
'content' => 'Contenu',
])->save();
URL::locale() // Returns the locale in the current URL
URL::switchLanguage('fr') // Returns the current url with different locale
Lang::active('fr') // Check if fr is the current locale
Lang::setInternalLocale('fr') // Set both the locale with the Translator class and setlocale method
Lang::valid('fr') // Check if a locale is valid
Lang::sanitize('fr') // Returns the locale if valid, or the default locale if not
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.