1. Go to this page and download the library: Download hyperlinkgroup/linguist 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/ */
hyperlinkgroup / linguist example snippets
return [
/*
|--------------------------------------------------------------------------
| Linguist API URL
|--------------------------------------------------------------------------
*/
'url' => env('LINGUIST_URL', 'https://api.linguist.eu/v2'),
/*
|--------------------------------------------------------------------------
| Linguist Project Slug
|--------------------------------------------------------------------------
*/
'project' => env('LINGUIST_PROJECT', ''),
/*
|--------------------------------------------------------------------------
| Linguist API Token
|--------------------------------------------------------------------------
*/
'token' => env('LINGUIST_TOKEN', ''),
/*
|--------------------------------------------------------------------------
| Linguist API Token Settings URL
|--------------------------------------------------------------------------
*/
'api_tokens_url' => env('LINGUIST_API_TOKENS_URL', 'https://app.linguist.eu/settings/api-tokens'),
/*
|--------------------------------------------------------------------------
| Temporary Directory for Translations while processing
|--------------------------------------------------------------------------
*/
'temporary_directory' => 'tmp/translations',
/*
|--------------------------------------------------------------------------
| Pull Minified
|--------------------------------------------------------------------------
| When enabled, pulled translation files are written as minified JSON.
| By default, files are pretty-printed for readability and easier diffing.
|--------------------------------------------------------------------------
*/
'pull_minified' => env('LINGUIST_PULL_MINIFIED', false),
];
use Hyperlinkgroup\Linguist\Events\SyncCompleted;
use Illuminate\Support\Facades\Event;
Event::listen(SyncCompleted::class, function (SyncCompleted $event): void {
logger()->info('Linguist sync completed', [
'project' => $event->projectSlug,
'keys_processed' => $event->result->keysProcessed,
]);
});
use Hyperlinkgroup\Linguist\Services\LinguistApiClient;
use Hyperlinkgroup\Linguist\Actions\SyncTranslations;
// API Client
$client = app(LinguistApiClient::class);
$projects = $client->listProjects()->json('data');
// Sync Action
$result = SyncTranslations::run(
projectSlug: 'my-project',
pruneRemoteKeys: true,
);
echo $result->getSummaryMessage();