Problem/Motivation

When adding a boolean base field to an entity and add that field to a View and I want to use a custom text for the on/off labels, those labels cannot be translated.
This was fixed for normal fields in #2849529: Unable to translate boolean custom true and false strings in views

Steps to reproduce

Add a boolean base field to an entity
Create a view of that entity
Add the base field as a field to the view
Set the output format to Custom
Add a custom on label
Save the View
Go to translate the View

Expected behaviour:
The custom label can be translated

Actual behaviour:
The custom label doesn't appear in the translation interface

Proposed resolution

Set the custom texts to be labels and not strings in the schema

Remaining tasks

Discuss if this needs tests, previous changes to switch schema from untranslatable to translatable didn't need tests for those particular strings

User interface changes

Configurable strings can be translated

API changes

None

Data model changes

None

Release notes snippet

Comments

Lendude created an issue. See original summary.

lendude’s picture

Title: Views boolean base field with custom on/off labels cannot be translated » Views showing a boolean base field with custom on/off labels cannot translate those labels
StatusFileSize
new613 bytes

Here we go, this makes these strings translatable.

lendude’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

Could we add a simple test case to show those fields are now translatable?

Also will this require an update path for existing sites or no since it's updating the schema not adding new values?

lendude’s picture

Category: Bug report » Task
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new536 bytes
new1.23 KB

@smustgrave thanks for the review!

We generally don't do tests for these schema type changes, since the test would be testing the translation interface and not so much the change we are making here (they are also very hard to test properly). With that in mind, I've changed this to a task and not a bug.

It does indeed need an update to clear the schema cache, so added that.

smustgrave’s picture

Status: Needs review » Needs work

Seems to have a build failure

error: patch failed: core/modules/views/views.post_update.php:63
error: core/modules/views/views.post_update.php: patch does not apply

lendude’s picture

Version: 10.0.x-dev » 10.1.x-dev

Ah, I rolled it against 10.1, lets stick it in there first, worry about backports later

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB

Attached patch for 10.0.x

nod_’s picture

Issue tags: +no-needs-review-bot
smustgrave’s picture

Status: Needs review » Needs work

Targeting 10.1 on this one first.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new1.24 KB

Rerolled patch #8 for 10.1.x branch, please review it.

Thanks & Regards,
Mrinalini

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

changes look good

  • longwave committed 7e8f000e on 10.1.x
    Issue #3336414 by Lendude, Gauravvv, mrinalini9, smustgrave: Views...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 10.1.x, thanks! This one doesn't seem critical to backport and we don't usually backport anything with a post-update hook.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.