PHP code example of c33s / i18n-helper-behavior

1. Go to this page and download the library: Download c33s/i18n-helper-behavior 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/ */

    

c33s / i18n-helper-behavior example snippets




use C33s\Behavior\I18nHelper\I18nModelInterface;

class BaseBook extends BaseObject implements Persistent, I18nModelInterface
{
    // ...
    
    // c33s_i18n_helper behavior

    /**
     * Get all available translations of the "Title" column.
     * This returns an associative array with locale => value pairs.
     *
     * @return array
     */
    public function getI18nTitle()
    {
        // ...
    }

    /**
     * Set translations of the "Title" column.
     * Accepts an associative array with locale => value pairs.
     *
     * @return Book
     */
    public function setI18nTitle($allTitles)
    {
        // ...
    }

    /**
     * Get i18n value of the "Title" column, using locale fallback (reverse default locales)
     * if the value is empty.
     * Starts with either the given locale or the current/default locale, set previously using getTranslation().
     *
     * @param string $locale
     *
     * @return mixed
     */
    public function getTitleWithFallback($locale = null)
    {
        // ...
    }
    
    /**
     * Set an array of default locales to use for the c33s_i18n_helper behavior (getI18n*(), get*WithFallback()).
     *
     * @param array $locales
     *
     * @return Book
     */
    public function setI18nDefaultLocales(array $locales)
    {
        // ...
    }

    /**
     * Get an array of default locales used by the c33s_i18n_helper behavior (getI18n*(), get*WithFallback()).
     *
     * @return array
     */
    public function getI18nDefaultLocales()
    {
        // ...
    }
}