- Issue created by @Anybody
There doesn't seem to be a non-translatable alternative to "text" and "text_format" in the configuration schema.
Overriding the "translatable" value for type: text
or type: text_format
isn't possible.
If you need a schema with a multiline string (or even a WYSIWYG input) that is not translatable, there doesn't seem to be such a type available in core?
See the following example:
example.settings:
type: config_object
label: 'Example schema.yml with a multiline text that should not be translatable'
mapping:
copyrights:
type: mapping
label: 'Copyrights'
# Copyrights should be kept in sync across all languages (=not translatable).
translatable: false
mapping:
value:
type: text
label: 'Text'
# Copyrights should be kept in sync across all languages (=not translatable).
translatable: false
format:
type: string
label: 'Text format'
text
is defined as follows in core/config/schema/core.data_types.schema.yml
# Human readable string that can contain multiple lines of text or HTML.
text:
type: string
label: 'Text'
translatable: true
constraints:
Regex:
# Disallow all control characters except for tabs (ASCII 9, 0x09) as well
# as carriage returns (ASCII 13, 0x0D) and line feeds (ASCII 10, 0x0A),
# which are used for line endings:
# - Windows: `\r\n`
# - old macOS: `\r`
# - *nix: `\n`
# @see https://stackoverflow.com/a/66587087
pattern: '/([^\PC\x09\x0a\x0d])/u'
match: false
message: 'Text is not allowed to contain control characters, only visible characters.'
text_format
is defined as follows in core/config/schema/core.data_types.schema.yml
# Text with a text format.
text_format:
type: mapping
label: 'Text with text format'
# We declare the entire mapping of text and text format as translatable. This
# causes the entire mapping to be saved to the language overrides of the
# configuration. Storing only the (to be formatted) text could result in
# security problems in case the text format of the source text is changed.
translatable: true
mapping:
value:
type: text
label: 'Text'
# Mark the actual text as translatable (in addition to the entire mapping
# being marked as translatable) so that shipped configuration with
# formatted text can participate in the string translation system.
translatable: true
format:
type: string
label: 'Text format'
# The text format should not be translated as part of the string
# translation system, so this is not marked as translatable.
It would me good to either have untranslated alternatives to
text
text_format
Or have the ability to override their translatability with
translatable: false
for such cases, which is at least complictated or even impossible for text_format
due to the several levels.
My current workaround is for now:
example.settings:
type: config_object
label: 'Example schema.yml with a multiline text that should not be translatable'
mapping:
copyrights:
type: mapping
label: 'Copyrights'
# Copyrights should be kept in sync across all languages (=not translatable).
translatable: false
mapping:
value:
type: string
label: 'Text'
# Copyrights should be kept in sync across all languages (=not translatable).
translatable: false
format:
type: string
label: 'Text format'
but the type: string
is not represented as multiline.
Active
11.0 π₯
Last updated