Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3359158
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:50:19+00:00 2026-05-18T02:50:19+00:00

I am tasked with i18n-ing our current CMS setup in Drupal. The problem that

  • 0

I am tasked with i18n-ing our current CMS setup in Drupal.
The problem that I am facing is with use of module_invoke() to place blocks within nodes.

I have managed to string translate blocks, and that is working when a block is placed in a region (block content is successfully translated) using the UI.

However, when a block is injected into a node like such:

$block = module_invoke('block', 'block', 'view', 22); print $block['content'];

It is not getting translated, or even worse, not showing at all.

I have also tried this variation using t(). e.g.:

$block = module_invoke('block', 'block', 'view', 22); print t($block['content']);

to no avail.

Generally speaking I’ve having a bit of trouble with blocks for i18n. Does anyone have a recommended approach for dealing with blocks in drupal with regards to translating them? I would prefer not to create different blocks for each language.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:50:19+00:00Added an answer on May 18, 2026 at 2:50 am

    So .. After digging around in the bowels of Drupal – and much hair pulling .. I’ve come up with an almost decent solution.

    Basically, with this function, I can extract a translated version of a block:

    function render_i18n_block($block_id, $region = "hidden"){
    
        if ($list = block_list($region)) {
            foreach ($list as $key => $block) {
              // $key == <i>module</i>_<i>delta</i>
              $key_str = "block_".$block_id;
              if ($key_str == $key){
              return theme('block', $block);
              }
            }
        }
    }
    

    Then, in my node, I simple call:

    <?php echo render_i18n_block(<block_id>,<region>); ?>
    

    There can be some issues where your blocks might not be displaying in a region (and therefore you can’t pass a region into block_list). For this case, I simply created a region called “hidden” which is not rendered anywhere in my template, but can be used to call block_list.

    Finally (and this is the part that I still need to find a good solution for), I discovered that block_list() in: includes/blocks/block.inc has a bit of an issue.

    It appears that $theme_key is not reliably set unless block_list() is being called from the theme() function (in includes/themes.inc) .. this causes the SQL to return an empty results set. The SQL looks like this:

    $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
    

    As you can see, if theme_key is not set, then it will just return an empty result.
    For now I am bypassing this by simply adding:

    if (!isset($theme_key)){$theme_key="<my_theme_name>";}
    

    in modules/blocks/block.inc::block_list() around line 429 .. I still need to work out a better way to do this.

    • 10 for anyone with suggestions on how I could ensure that $theme_key is set before calling block_list 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been tasked to build a system that allows someone in our company to
We are tasked with creating a reporting frameworks that does the following. Clients can
I am tasked with writing a WPF app that performs crud on 100 or
I have been tasked to look after an ASP.Net WebForms application that communicates with
I have been tasked with figuring out a state space for a problem based
I’ve been tasked with implementing a system for continuously receiving large amounts of data
I'm tasked with reading a large text file (around 150 MB), parsing it and
I've recently been tasked with adding logging statements to every method call in a
I've recently been tasked with porting a large codebase of C++ code to XNA,
I'm tasked with creating a model of a cage of hardware. Each cage contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.