1. Go to this page and download the library: Download sirgrimorum/transarticles 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/ */
sirgrimorum / transarticles example snippets
return [
// Eloquent model used to store articles
'default_articles_model' => \Sirgrimorum\TransArticles\Models\Article::class,
// Database column that stores the locale code
'default_lang_column' => 'lang',
// Model scope used to find a single article
'default_findarticle_function_name' => 'findArticle',
// Model scope used to find a collection of articles
'default_findarticles_function_name' => 'findArticles',
// JavaScript global variable for exposed articles
'default_base_var' => 'translations',
];
use Sirgrimorum\TransArticles\Facades\TransArticles;
// Returns content for the current locale (or fallback)
$html = TransArticles::get('homepage.hero_title');
// Expose a scope as a <script> tag
$script = TransArticles::getjs('homepage');
echo trans_article('homepage.hero_title');
TransArticles::get(string $nickname): string
TransArticles::getjs(
string $scope, // Scope to expose (or 'scope.nickname' for a single article)
string $basevar = '' // JS global variable (defaults to config 'default_base_var')
): string