PHP code example of rogervila / laravel-csv-translations
1. Go to this page and download the library: Download rogervila/laravel-csv-translations 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/ */
rogervila / laravel-csv-translations example snippets
// config/lang.php
return [
'csv' => [
'enabled' => (bool) env('CSV_TRANSLATIONS_ENABLED', true),
// You might use a custom resolver to get CSV data from elsewhere
'resolver' => \LaravelCSVTranslations\CSVLocalFileResolver::class,
'throw_missing_file_exception' => false,
'cache' => [
'key' => \LaravelCSVTranslations\CSVLoader::class,
'store' => 'array',
'seconds' => 0,
],
]
];
// config/lang.php
return [
'csv' => [
'resolver' => \App\Lang\RemoteCSVFileResolver::class,
]
];
// app/Lang/RemoteCSVFileResolver.php
namespace App\Lang;
use LaravelCSVTranslations\CSVResolverInterface;
class RemoteCSVFileResolver implements CSVResolverInterface
{
public function resolve(): array
{
// Return the CSV formatted data
}
}
// If TranslationServiceProvider is correctly configured, 'translation.loader' should be an instance of CSVLoader
/** @var CSVLoader $loader */
$loader = $this->app['translation.loader'];
// Raw method returns an associative array with all translation keys and their raw values
$raw = $loader->raw('ca')
/*
[
"greetings.good_morning" => "Bon dia, :name!",
// ...
]
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.