: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:: database_adapters .. py:attribute:: name .. 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:: read(skel, *args, **kwargs) :classmethod: Read Skeleton with *key* from the datastore into the Skeleton. If not key is given, skel["key"] will be used. Reads all available data of entity kind *kindName* and the key *key* from the Datastore into the Skeleton structure's bones. Any previous data of the bones will discard. To store a Skeleton object to the Datastore, see :func:`~viur.core.skeleton.Skeleton.write`. :param key: A :class:`viur.core.db.Key`, string, or int; from which the data shall be fetched. If not provided, skel["key"] will be used. :param create: Allows to specify a dict or initial callable that is executed in case the Skeleton with the given key does not exist, it will be created. :returns: None on error, or the given SkeletonInstance on success. .. py:method:: write(skel, **kwargs) :classmethod: Write current Skeleton 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.read`. :param key: Allows to specify a key that is set to the skeleton and used for writing. :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 Skeleton. .. py:class:: Translation(*args, **kwargs) Bases: :py:obj:`viur.core.prototypes.list.List` The Translation module is a system module used by the ViUR framework for its internationalization capabilities. .. py:attribute:: kindName .. py:attribute:: roles .. py:attribute:: cloneSkel .. py:attribute:: _last_reload .. py:method:: adminInfo() .. py:method:: addSkel() Returns a custom TranslationSkel where the name is editable. The name becomes part of the key. .. 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:: dump(*, pattern = None, language = None) Dumps translations as JSON. :param pattern: Optional, provide fnmatch-style translation key filter patterns of the translations wanted. :param language: Allows to request a specific language. By default, the language of the current request is used. :return: A dictionary with translations as JSON. Structure: ``{language: {key: value, ...}, ...}`` Example calls: - `/json/_translation/dump?pattern=viur.*` get viur.*-translations for current language - `/json/_translation/dump?pattern=viur.*&language=en` for english translations - `/json/_translation/dump?pattern=viur.*&language=en&language=de` for english and german translations - `/json/_translation/dump?pattern=viur.*&language=*` for all available language .. py:method:: get_public(*, languages = [], **kwargs)