:py:mod:`core.modules.translation` ================================== .. py:module:: core.modules.translation Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: core.modules.translation.Creator core.modules.translation.TranslationSkel core.modules.translation.Translation .. py:class:: Creator Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: VIUR :value: 'viur' .. py:attribute:: USER :value: 'user' .. py:class:: TranslationSkel(*args, **kwargs) Bases: :py:obj:`viur.core.skeleton.Skeleton` This is a container-object holding information about one database entity. It has to be sub-classed with individual information about the kindName of the entities and its specific data attributes, the so called bones. The Skeleton stores its bones in an :class:`OrderedDict`-Instance, so the definition order of the contained bones remains constant. :ivar key: This bone stores the current database key of this entity. Assigning to this bones value is dangerous and does *not* affect the actual key its stored in. :vartype key: server.bones.BaseBone :ivar creationdate: The date and time where this entity has been created. :vartype creationdate: server.bones.DateBone :ivar changedate: The date and time of the last change to this entity. :vartype changedate: server.bones.DateBone .. py:attribute:: kindName .. py:attribute:: tr_key .. py:attribute:: translations .. py:attribute:: translations_missing .. py:attribute:: default_text .. py:attribute:: hint .. py:attribute:: usage_filename .. py:attribute:: usage_lineno .. py:attribute:: usage_variables .. py:attribute:: creator .. py:attribute:: public .. py:method:: toDB(skelValues, **kwargs) :classmethod: Store current Skeleton entity to the Datastore. Stores the current data of this instance into the database. If an *key* value is set to the object, this entity will ne updated; Otherwise a new entity will be created. To read a Skeleton object from the data store, see :func:`~viur.core.skeleton.Skeleton.fromDB`. :param update_relations: If False, this entity won't be marked dirty; This avoids from being fetched by the background task updating relations. :returns: The datastore key of the entity. .. py:method:: preProcessSerializedData(skelValues, entity) :classmethod: Can be overridden to modify the :class:`viur.core.db.Entity` before its actually written to the data store. .. py:class:: Translation(*args, **kwargs) Bases: :py:obj:`viur.core.prototypes.list.List` List module prototype. The list module prototype handles datasets in a flat list. It can be extended to filters and views to provide various use-cases. It is undoubtedly the most frequently used prototype in any ViUR project. .. py:attribute:: kindName .. py:attribute:: roles .. py:attribute:: _last_reload .. py:method:: adminInfo() .. py:method:: onAdded(*args, **kwargs) Hook function that is called after adding an entry. It should be overridden for a module-specific behavior. The default is writing a log entry. :param skel: The Skeleton that has been added. .. seealso:: :func:`add`, , :func:`onAdd` .. py:method:: onEdited(*args, **kwargs) Hook function that is called after modifying an entry. It should be overridden for a module-specific behavior. The default is writing a log entry. :param skel: The Skeleton that has been modified. .. seealso:: :func:`edit`, :func:`onEdit` .. py:method:: onDeleted(*args, **kwargs) Hook function that is called after deleting an entry. It should be overridden for a module-specific behavior. The default is writing a log entry. :param skel: The Skeleton that has been deleted. .. seealso:: :func:`delete`, :func:`onDelete` .. py:method:: _reload_translations() .. py:method:: get_public(*, languages = [], pattern = '*') Dumps public translations as JSON. :param languages: Allows to request a specific language. :param pattern: Provide an fnmatch-style key filter pattern Example calls: - `/json/_translation/get_public` get public translations for current language - `/json/_translation/get_public?languages=en` for english translations - `/json/_translation/get_public?languages=en&pattern=bool.*` for english translations, but only keys starting with "bool." - `/json/_translation/get_public?languages=en&languages=de` for english and german translations - `/json/_translation/get_public?languages=*` for all available languages