Without a correct schema, core is not able to pick translatable fields.

So the buttons can hardly be used on multilingual site, because the button text and messages are not translated.

Did I miss something? No, not you ;-)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hexabinaer created an issue. See original summary.

tobiasb made their first commit to this issue’s fork.

tobiasb’s picture

Category: Task » Bug report
Status: Active » Needs review
StatusFileSize
new8.3 KB

Patch file for composer.

mmbk’s picture

Title: Translating the button text impossible? » Add missing schema information
Issue summary: View changes
mmbk’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Patch #4 works as expected.

laboratory.mike’s picture

Thanks Tobias for the patch. I'll review it in the near future and get it merged in.

mmbk’s picture

Assigned: Unassigned » mmbk
Status: Reviewed & tested by the community » Needs work

Found a problem here

+++ b/src/Plugin/views/area/ViewsAddButtonArea.php
@@ -326,7 +323,7 @@ class ViewsAddButtonArea extends TokenizeAreaPluginBase {
-      $text = $this->options['button_text'] ? $this->options['button_text'] : 'Add ' . $bundle;
+      $text = $this->options['button_text'] ? $this->options['button_text'] : $this->t('Add @bundle', ['@bundle' => $bundle]);
       $text = $this->options['tokenize'] ? $this->tokenizeValue($text) : $text;
       $text = t($text);

Found a problem here, when no custom text is configured, the t() in line 329 fails, because the argument is missing.

tobiasb’s picture

I did not saw $text = t($text); . This can then be removed. Because when configured via views -> translate it via config translation, when the button_text is empty use Add @bundle -> can be translated via UI-Translation.

sourabhjain made their first commit to this issue’s fork.

sourabhjain’s picture

Status: Needs work » Needs review
mmbk’s picture

Assigned: mmbk » Unassigned
Status: Needs review » Reviewed & tested by the community

Yes it's working and not crashing anymore

tobiasb’s picture

StatusFileSize
new8.34 KB

Patch file for composer again. ;-)

tobiasb’s picture

StatusFileSize
new11.27 KB

The default button text was the bundle ID. I changed the patch so that it use the bundle label.

laboratory.mike’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for your contribution @tobiasb! I've merged this into the codebase, and will include it in the next release.

Status: Fixed » Closed (fixed)

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