PHP code example of vkr / translation-bundle
1. Go to this page and download the library: Download vkr/translation-bundle 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/ */
vkr / translation-bundle example snippets
public function getTranslatableFields()
{
return ['name'];
}
private $name;
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getName()
{
return $this->name;
}
$field
public function getTranslationFallback($field = '')
{
if ($field == 'name') {
return $this->getSlug();
}
if ($field == 'description) {
return 'foo';
}
return '';
}
$translationManager = $this->get('vkr_translation.translation_manager');
$translatedEntity = $translationManager->translate($entity);