\TranslatableDataObject
Translatable extension, inspired by Uncle Cheese's implementation https://github.com/unclecheese/TranslatableDataObject but tailored to be used with the translatable SilverStripe extension
- Author: bummzack
Synopsis
class TranslatableDataObject
extends DataExtension
{
- // members
- private static array $default_field_types = ;
- private static $locales = NULL;
- protected static array $arguments = ;
- protected static array $collectorCache = ;
- protected static array $localizedFields = ;
- protected static array $collectorLock = ;
- // methods
- public static Config_ForClass config()
- public static void get_extra_config()
- private static bool is_translatable_installed()
- public void updateCMSFields()
- public TabSet getTranslatableTabSet()
- public FormField getLocalizedFormField()
- public FormField getLocalizedRelationField()
- public string|DBField T()
- public void updateFieldLabels()
- public bool isLocalizedField()
- public null|string getLocalizedFieldName()
- public bool isLocalizedRelation()
- public void getLocalizedRelation()
- public string|DBField getLocalizedValue()
- public boolean canTranslate()
- public void onBeforeWrite()
- protected string getBasename()
- protected string getLocale()
- public static array get_localized_class_fields()
- public static string localized_field()
- public static void set_default_fieldtypes()
- public static mixed get_default_fieldtypes()
- public static void set_locales()
- public static array|null get_locales()
- protected static array collectDBFields()
- protected static array collectHasOneRelations()
- protected static array get_target_locales()
- protected static array|null get_arguments()
- public void setFieldForRelation()
- public void getFieldForRelation()
Hierarchy
Extends
- DataExtension
Tasks
Line | Task |
---|---|
249+ | default field for has_one? |
285 | throw an exception? |
Members
private
- $default_field_types
- $locales
protected
- $arguments — array
- $collectorCache
- $collectorLock
- $localizedFields
Methods
private
protected
- collectDBFields() — Collect all additional database fields of the given class.
- collectHasOneRelations() — Collect all additional has_one relations of the given class.
- getBasename() — Given a translatable field name, pull out the locale and return the raw field name.
- getLocale() — Given a translatable field name, pull out the raw field name and return the locale
- get_arguments() — Get the custom arguments for a given class. Either directly from how the extension was defined, or lookup the 'translatable_fields' static variable
- get_target_locales() — Get the locales that should be translated
public
- T() — A template accessor used to get the translated version of a given field.
- canTranslate() — Check whether or not the given member is allowed to edit the given locale Caution: Does not consider the {@link canEdit()} permissions.
- config() — Accessor to the config variables
- getFieldForRelation()
- getLocalizedFieldName() — Get the field name in the current reading locale
- getLocalizedFormField() — Get a form field for the given field name
- getLocalizedRelation() — Get the localized object for a given relation.
- getLocalizedRelationField() — Get a form field for the given relation name
- getLocalizedValue() — Get the localized value for a given field.
- getTranslatableTabSet() — Get a tabset with a tab for every language containing the translatable fields.
- get_default_fieldtypes() — Get the default field-types
- get_extra_config() — Use table information and locales to dynamically build required table fields
- get_locales() — Get the list of locales that should be translated.
- get_localized_class_fields() — Get an array with all localized fields for the given class
- isLocalizedField() — Check if the given field name is a localized field
- isLocalizedRelation() — Check if the given field name is a localized has_one relation
- localized_field() — Given a field name and a locale name, create a composite string that represents the field in the database.
- onBeforeWrite() — On before write hook.
- setFieldForRelation() — Setter for relation specific FormField. Will be cloned in scaffolding functions
- set_default_fieldtypes() — Set the default field-types that should be translated.
- set_locales() — Explicitly set the locales that should be translated.
- updateCMSFields() — Alter the CMS Fields in order to automatically present the correct ones based on current language.
- updateFieldLabels() — Present translatable form fields in a more readable fashion