It seems that, there is no where to do this.
I looked into the code
I believe it is something to do with this file.
Plugin/DisplayVariant/ContextBlockPageVariant.php
125 private function getBuildFromBlockLayout() {
126 $plugin_manager = \Drupal::service('plugin.manager.display_variant');
127 $display_variant = $plugin_manager->createInstance('block_page', $plugin_manager->getDefinition('block_page'));
128 $display_variant->setTitle($this->title);
129
130 return $display_variant->build();
131 }
132
If we put t() to line 128 in the setTitle
The problem will be solved by using the Drupal8 UI Translation tool to translate it.
If we are going to do this, I suggest we put optional context parameter to t function, so this translation is limited only for Context Module.
I don't know anything else about how core Drupal8 store translation for Block Title, we can also do that. but it means you need to link the dropbutton to the translate button and etc..
Please discuss, I can provide a very simple patch if we are going for the first option.. which is adding t() to line 128 with the context parameter.
Issue fork context-2922368
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
Comment #2
Priyanka.addweb CreditAttribution: Priyanka.addweb at AddWeb Solution Pvt. Ltd. commentedYou can make block twig file and use t() function for translation. For label use {{ label|t }} in twig file.
Comment #3
tahiticlic CreditAttribution: tahiticlic commentedHi,
this solution is not perfect since it's not applicable in all cases. For instance, for a wysiwyg field, it won't work.
Perhaps a proper solution would have the translate link through Context UI.
Regards
Comment #4
boshtian CreditAttribution: boshtian at Agiledrop - Your Trusted Drupal Teammates commentedWhat kind of block do you have? Is this a Custom block, something out of Views or you made your own block in code?
The point is that some block types are translatable, so we would need more information so we can determine what would be the best solution that would cover all cases.
Comment #5
s.thiru.raju CreditAttribution: s.thiru.raju as a volunteer commentedI'm using custom block and using Panels. Not able to translate block title. I could find some solutions about translating Description. But would require a solution for translating custom block title. Thank you
Comment #6
ThirstySix CreditAttribution: ThirstySix as a volunteer commentedOverriding the block title in panels:
Comment #7
rooby CreditAttribution: rooby commentedSee https://www.drupal.org/node/45111 for priority descriptions.
This one doesn't seem to be critical.
Comment #8
Sutharsan CreditAttribution: Sutharsan at LimoenGroen commentedChanging to Bug as it is for the multilingual use of the Context module.
Comment #9
strozx CreditAttribution: strozx commentedComment #10
DeaOm CreditAttribution: DeaOm at Agiledrop - Your Trusted Drupal Teammates commentedI tested this one out, and it seems to be working. Not sure if I completely understand the issue tough. I could translate the title of the block in the UI by searching that string (tested with core's Recent content, which is a view block), but that then applies to blocks added via context or via block structure. The custom block is then translated via Configuration translation, and it's also working and displaying the correct translation depending on the language.
Leaving this status to postponed, but if no additional steps to reproduce are added, it will be assumed it's working correctly.
Comment #11
marcvangendIf I understand correctly and the original issue is about the same problem I'm facing right now, here are the steps to reproduce:
/fr
to the URL.Comment #12
marcvangendOK, I lied a little when I said "You can't". There seems to be a workaround if you don't mind manually editing configuration Yaml files:
config/sync/context.context.sitewide.yml
if the machine name is "sitewide".config/sync/language/fr/context.context.sitewide.yml
. If not, create it.You can leave out all other properties, only add the label property you need to translate and the parent keys that lead to it (reactions>blocks>blocks>[UUID]). Take care because Yaml is indentation-sensitive.
Disclaimer: Even though this works (at the moment, for me) this is not an officially supported method. It comes without guarantees and may break at any moment.
Comment #15
vlad.dancerHey @DeaOm
I can't reproduce translating block title via `User interface translation`.
The Recent Content block's title isn't translated via t() function. Instead you've might translated strings with `Recent content` for other sources, like from: core/modules/help_topics/help_topics/tracker.tracking_changed_content.html.twig
Ha! You've found some bug. This block shouldn't be translatable in such way.
@marcvangend
I'm too lazy for it :)
I've looked into the context's schema definitions and found that we could translate block's title.
We need just to change value for the `reaction.plugin.mapping.blocks.sequence.mapping.label.type` property to the `label` type.
I checked translating various block provides: content blocks, user blocks, powered by, search block.
So for anyone who can't wait you could alter schema definition yourself:
Clear the caches.
Then go to admin/structure/context/[your_context]/translate and it under: reactions > reaction > blocks > your_block
Note: don't forget to disable Override title in a context block's settings page.
Comment #16
marcvangendThanks for the merge request, Vlad! Myself, I was too lazy to figure out how to make that label translatable... So I was happy to learn from your commit :-D
Comment #17
Sutharsan CreditAttribution: Sutharsan at LimoenGroen commentedThis is indeed the right way to translate the configuration. Patch looks good. Have not tested it, but this can't go wrong (famous last words ;) )
Comment #20
paulocs