Languages

This package contains both language-related data models: Language and LanguageTreeNode

Language

class integreat_cms.cms.models.languages.language.Language(*args, **kwargs)[source]

Bases: AbstractBaseModel

Data model representing a content language.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • slug (SlugField) – Language Slug. Unique string identifier used in URLs without spaces and special characters.

  • bcp47_tag (SlugField) –

    BCP47 Tag. Language identifier without spaces and special characters. This field usually contains a combination of subtags from the IANA Subtag Registry.

    The recommended minimum buffer for bcp47 is 35. It’s unlikely that we have language slugs longer than 8 characters though. See RFC 5646 Section 4.4.1. Registered tags: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

  • native_name (CharField) – Native name. The name of the language in this language.

  • english_name (CharField) – Name in English. The name of the language in English.

  • text_direction (CharField) –

    Text direction

    Manage choices in text_directions

  • primary_country_code (CharField) –

    Primary country flag. The country with which this language is mainly associated. This flag is used to represent the language graphically.

    Manage choices in countries

  • secondary_country_code (CharField) –

    Secondary country flag. Another country with which this language is also associated. This flag is used in the language switcher.

    Manage choices in countries

  • language_color (CharField) –

    Language color. This color is used to represent the color label of the chosen language

    Manage choices in language_color

  • created_date (DateTimeField) – Creation date

  • last_updated (DateTimeField) – Modification date

  • table_of_contents (CharField) – “Table of contents” in this language. The native name for “Table of contents” in this language. This is used in exported PDFs.

  • social_media_webapp_title (CharField) – Social media title of the WebApp. Displayed title of the WebApp in the search results and on social media pages (max 100 characters).

  • social_media_webapp_description (TextField) – Social media description. Displayed description of the WebApp in the search results and on social media pages (max 200 characters).

  • message_content_not_available (CharField) – “This page does not exist in the selected language. It is however available in these languages:” in this language. This is shown to the user when a page is not available in their language.

  • message_partial_live_content_not_available (CharField) – “Part of the page does not exist in the selected language. It is however available in these languages:” in this language. This is shown to the user when the mirrored part of a page is not available in their language.

Reverse relationships:

Parameters:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

active_in_regions[source]

Returns regions in which the language is active

Returns:

regions in which the language is active

bcp47_tag[source]

Type: SlugField

BCP47 Tag. Language identifier without spaces and special characters. This field usually contains a combination of subtags from the IANA Subtag Registry.

The recommended minimum buffer for bcp47 is 35. It’s unlikely that we have language slugs longer than 8 characters though. See RFC 5646 Section 4.4.1. Registered tags: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

can_be_pdf_exported[source]

Returns whether PDF export is allowed for the language

Returns:

whether PDF export is allowed for the language

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <Language: Language object (id)>. It is used for logging.

Returns:

The canonical string representation of the language

Return type:

str

language_color[source]

Type: CharField

Language color. This color is used to represent the color label of the chosen language

Choices:

  • #FFBB78

  • #2CA02C

  • #FF9896

  • #C5B0D5

  • #FF4500

  • #FFA500

  • #17157D

  • #1F77B4

  • #FFD700

  • #008080

  • and 33 more

Manage choices in language_color

primary_country_code[source]

Type: CharField

Primary country flag. The country with which this language is mainly associated. This flag is used to represent the language graphically.

Choices:

  • ab

  • ad

  • ae

  • af

  • al

  • am

  • ao

  • ar

  • at

  • au

  • and 165 more

Manage choices in countries

save(*args: Any, **kwargs: Any) None[source]

This overwrites the default Django save() method, to invalidate the cache of the related objects.

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied kwargs

Return type:

None

secondary_country_code[source]

Type: CharField

Secondary country flag. Another country with which this language is also associated. This flag is used in the language switcher.

Choices:

  • ab

  • ad

  • ae

  • af

  • al

  • am

  • ao

  • ar

  • at

  • au

  • and 165 more

Manage choices in countries

text_direction[source]

Type: CharField

Text direction

Choices:

  • LEFT_TO_RIGHT

  • RIGHT_TO_LEFT

Manage choices in text_directions

translated_name[source]

Returns the name of the language in the current backend language

Returns:

The translated name of the language

visible_in_regions[source]

Returns regions in which the language is visible

Returns:

regions in which the language is visible

Language Tree Node

class integreat_cms.cms.models.languages.language_tree_node.LanguageTreeNode(*args, **kwargs)[source]

Bases: AbstractTreeNode

Data model representing a region’s language tree. Each tree node is a single object instance and the whole tree is identified by the root node. The base functionality inherits from the package django-treebeard <https://django-treebeard.readthedocs.io/en/latest/>.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

children (Reverse ForeignKey from LanguageTreeNode) – All children of this language tree node (related name of parent)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

english_name[source]

Returns the name of this node’s language in English

Returns:

The English name of this language node

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <LanguageTreeNode: LanguageTreeNode object (id)>. It is used for logging.

Returns:

The canonical string representation of the language node

Return type:

str

mt_provider[source]

Return the preferred machine translation provider if valid, or the first available provider, or None

Returns:

The MT provider for this target language

mt_providers[source]

Return the list of supported machine translation providers

Returns:

The MT provider for this target language

native_name[source]

Returns the native name of this node’s language

Returns:

The native name of this language node

slug[source]

Returns the slug of this node’s language

Returns:

The language slug of this language node

text_direction[source]

Returns the text direction (e.g. left-to-right) of this node’s language

Returns:

The text direction name of this language node

translated_name[source]

Returns the name of this node’s language in the current backend language

Returns:

The translated name of this language node