Overridable segments models
These models are responsible for storing details about overridable segments in a translation source and storing the overridden data as well.
Overriding segments within an object allows non-text data to be modified for each locale.
graph TD
A[OverridableSegment] --> C[TranslationSource]
A[OverridableSegment] --> D[TranslationContext]
B[SegmentOverride] --> D
B[SegmentOverride] --> E[wagtail.Locale]
style C stroke-dasharray: 5 5
style D stroke-dasharray: 5 5
style E stroke-dasharray: 5 5
SegmentOverride
Bases: Model
Stores the overridden value of an OverridableSegment.
Some segments are not translatable, but can be optionally overridden in translations. For example, images.
If an overridable segment is overridden by a user for a locale, the value to override the segment with is stored in this model.
Attributes:
Name | Type | Description |
---|---|---|
locale |
ForeignKey to Locale
|
The Locale to override. |
context |
ForeignKey to TranslationContext
|
The context to override. With the Locale, this tells us specifically which object/content path to override. |
last_translated_by |
User
|
The user who last updated this override. |
created_at |
DateTimeField
|
The date/time when the override was first created. |
updated_at |
DateTimeField
|
The date/time when the override was last updated. |
data_json |
TextField with JSON contents
|
The value to override the field with. |
has_error |
BooleanField
|
Set to True if the value of this overtride has an error. We store overrides with errors in case they were edited from an external system. This allows us to display the error in Wagtail. |
field_error |
TextField
|
if there was a database-level validation error while saving the translated object, that error is tored here. |
Source code in wagtail_localize/models.py
1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 |
|
get_error()
Returns a string containing any validation errors on the saved value.
Returns:
Name | Type | Description |
---|---|---|
str |
The validation error if there is one. |
|
None |
If there isn't an error. |
Source code in wagtail_localize/models.py
1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 |
|
set_field_error(error)
Returns a string containing any validation errors on the saved value.
Returns:
Name | Type | Description |
---|---|---|
str |
The validation error if there is one. |
|
None |
If there isn't an error. |
Source code in wagtail_localize/models.py
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 |
|
OverridableSegment
Bases: BaseSegment
Represents an overridable segment that was extracted from a TranslationSource.
Attributes:
Name | Type | Description |
---|---|---|
data_json |
TextField with JSON content
|
The value of the overridable segment as it is in the source. |
source |
ForeignKey to TranslationSource
|
The source content that the string was extracted from. |
context |
ForeignKey to TranslationContext
|
The context, which contains the position of the string in the source content. |
order |
PositiveIntegerField
|
The index that this segment appears on the page. |
Source code in wagtail_localize/models.py
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 |
|
data
property
Returns the decoded JSON data that's stored in .data_json