1. Go to this page and download the library: Download volcy/translator-core 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/ */
volcy / translator-core example snippets
use Volcy\Translator\Drivers\BladeDriver;
use Volcy\Translator\IdStrategies\HashIdStrategy;
use Volcy\Translator\ScanRunner;
use Volcy\Translator\Filesystem\NativeFilesystem;
use Volcy\Translator\ViewIndexPathResolver;
// Create components
$filesystem = new NativeFilesystem();
$resolver = new ViewIndexPathResolver();
$driver = new BladeDriver(new HashIdStrategy());
$scanRunner = new ScanRunner($driver, $filesystem, $resolver, new HashIdStrategy());
// Scan Blade views
$result = $scanRunner->run(
'/path/to/views',
'/path/to/indexes',
'en'
);
echo "Scanned {$result['written']} files\n";
foreach ($result['warnings'] as $warning) {
echo "Warning: $warning\n";
}
use Volcy\Translator\TranslationCatalog;
$catalog = new TranslationCatalog(
$filesystem,
$resolver,
'/path/to/indexes'
);
// Get translation dictionary for views
$dictionary = $catalog->forViewsAndLocale(
['home', 'layout', 'partials.header'],
'fr'
);
// Apply to rendered HTML
$html = '<h1>Welcome</h1><p>This is the home page</p>';
$translated = $catalog->applyToHtml($html, $dictionary);
use Volcy\Translator\IdStrategies\HashIdStrategy;
$driver = new BladeDriver(new HashIdStrategy());
use Volcy\Translator\IdStrategies\TagPathIdStrategy;
$driver = new BladeDriver(new TagPathIdStrategy());
use Volcy\Translator\IdStrategies\ExplicitIdStrategy;
$driver = new BladeDriver(new ExplicitIdStrategy());