kernel/classes/ezcontentlanguage.php
static function addLanguage( $locale, $name = null )
    {
        $localeObject = eZLocale::instance( $locale );
        if ( !$localeObject )
        {
            eZDebug::writeError( "No such locale $locale!", __METHOD__ );
            return false;
        }

        if ( $name === null )
        {
            $name = $localeObject->attribute( 'intl_language_name' );
        }

        $db = eZDB::instance();

        $languages = eZContentLanguage::fetchList( true );

        if ( ( $existingLanguage = eZContentLanguage::fetchByLocale( $locale ) ) )
        {
            eZDebug::writeWarning( "Language '$locale' already exists!", __METHOD__ );
            return $existingLanguage;
        }

        if ( count( $languages ) >= self::maxCount() )
        {
            eZDebug::writeError( 'Too many languages, cannot add more!', __METHOD__ );
            return false;
        }

        $db->lock( 'ezcontent_language' );

        $idSum = 0;
        foreach( $languages as $language )
        {
            $idSum += $language->attribute( 'id' );
        }

        // ID 1 is reserved
        $candidateId = 2;
        while ( $idSum & $candidateId )
        {
            $candidateId *= 2;
        }

        $newLanguage = new eZContentLanguage( array(
                                                  'id' => $candidateId,
                                                  'locale' => $locale,
                                                  'name' => $name,
                                                  'disabled' => 0 ) );
        $newLanguage->store();

        $db->unlock();

        eZContentLanguage::fetchList( true );

        // clear the cache
        eZContentCacheManager::clearAllContentCache();

        return $newLanguage;
    }
static function addLanguage( $locale, $name = null )
    {
        $localeObject = eZLocale::instance( $locale );
        if ( !$localeObject )
        {
            eZDebug::writeError( "No such locale $locale!", __METHOD__ );
            return false;
        }

        if ( $name === null )
        {
            $name = $localeObject->attribute( 'intl_language_name' );
        }

        $db = eZDB::instance();

        $languages = eZContentLanguage::fetchList( true );

        if ( ( $existingLanguage = eZContentLanguage::fetchByLocale( $locale ) ) )
        {
            eZDebug::writeWarning( "Language '$locale' already exists!", __METHOD__ );
            return $existingLanguage;
        }

        if ( count( $languages ) >= self::maxCount() )
        {
            eZDebug::writeError( 'Too many languages, cannot add more!', __METHOD__ );
            return false;
        }

        $db->lock( 'ezcontent_language' );

        $idSum = 0;
        foreach( $languages as $language )
        {
            $idSum += $language->attribute( 'id' );
        }

        // ID 1 is reserved
        $candidateId = 2;
        while ( $idSum & $candidateId )
        {
            $candidateId *= 2;
        }

        $newLanguage = new eZContentLanguage( array(
                                                  'id' => $candidateId,
                                                  'locale' => $locale,
                                                  'name' => $name,
                                                  'disabled' => 0 ) );
        $newLanguage->store();

        $db->unlock();

        eZContentLanguage::fetchList( true );

        // clear the cache
        eZContentCacheManager::clearAllContentCache();

        return $newLanguage;
    }
static function addLanguage ( $ locale , $ name = null ) { $ localeObject = eZLocale :: instance ( $ locale ) ; if ( ! $ localeObject ) { eZDebug :: writeError ( "No such locale $locale!" , __METHOD__ ) ; return false ; } if ( $ name === null ) { $ name = $ localeObject -> attribute ( 'intl_language_name' ) ; } $ db = eZDB :: instance ( ) ; $ languages = eZContentLanguage :: fetchList ( true ) ; if ( ( $ existingLanguage = eZContentLanguage :: fetchByLocale ( $ locale ) ) ) { eZDebug :: writeWarning ( "Language '$locale' already exists!" , __METHOD__ ) ; return $ existingLanguage ; } if ( count ( $ languages ) >= self :: maxCount ( ) ) { eZDebug :: writeError ( 'Too many languages, cannot add more!' , __METHOD__ ) ; return false ; } $ db -> lock ( 'ezcontent_language' ) ; $ idSum = 0 ; foreach ( $ languages as $ language ) { $ idSum += $ language -> attribute ( 'id' ) ; } // ID 1 is reserved $ candidateId = 2 ; while ( $ idSum & $ candidateId ) { $ candidateId *= 2 ; } $ newLanguage = new eZContentLanguage ( array ( 'id' => $ candidateId , 'locale' => $ locale , 'name' => $ name , 'disabled' => 0 ) ) ; $ newLanguage -> store ( ) ; $ db -> unlock ( ) ; eZContentLanguage :: fetchList ( true ) ; // clear the cache eZContentCacheManager :: clearAllContentCache ( ) ; return $ newLanguage ; }
Adds new language to the site.

\param locale Locale code (e.g. 'slk-SK') of language to add.
\param name Optional. Name of the language. If not specified, the international language name for the $locale locale
will be used.
\return eZContentLanguage object of the added language (or the existing one if specified language has been already used)
or false in case of any error (invalid locale code or already reached eZContentLanguage::maxCount() languages).
\static
Adds new language to the site .