/** * Update the field values for the files & images section * @see DataExtension::updateCMSFields() */ function updateCMSFields(FieldList $fields) { // only apply the update to files (not folders) if ($this->owner->class != 'Folder') { // remove all the translated fields $translatedFields = TranslatableDataObject::get_localized_class_fields($this->owner->class); if ($translatedFields) { foreach ($translatedFields as $fieldName) { $fields->removeByName($fieldName, true); } } // add the tabs from the translatable tab set to the fields $set = $this->owner->getTranslatableTabSet(); foreach ($set->FieldList() as $tab) { $fields->addFieldToTab('Root', $tab); } } }
/** * Explicitly set the locales that should be translated. * * @example * <code> * // Set locales to en_US and fr_FR * TranslatableDataObject::set_locales(array('en_US', 'fr_FR')); * </code> * * Defaults to `null`. In this case, locales are being taken from * Translatable::get_allowed_locales or Translatable::get_existing_content_languages * * @param array $locales an array of locales or null */ public static function set_locales($locales) { if (is_array($locales)) { foreach ($locales as $locale) { if (i18n::validate_locale($locale)) { if (!is_array(self::$locales)) { self::$locales = array(); } if (array_search($locale, self::$locales) === false) { self::$locales[] = $locale; } } } } else { self::$locales = null; } }