Can you cache blocks per language? I am working on a multilingual site right now, and am using the Internationalization suite of modules to build it out.

The site has some custom blocks in it that I would normally use DRUPAL_CACHE_GLOBAL in the hook_block_info() definition.  However, some of these will have translatable strings in them, so I really need to cache them per-language.

Is this possible?  Or, is my only real option to use DRUPAL_CACHE_PER_PAGE?
Just use DRUPAL_CACHE_GLOBAL. On multilingual sites the users language is part of the (cid), i.e. the key used when storing/fetching entries to/from the block cache.

The function responsible for this behavior is drupal_render_cid_parts which is called from _block_get_cache_id.

You can embed the following fragment into a custom PHP block in order to verify the mechanism:

$fakeblock = (object) array(
  'module' =&gt; 'some-module',
  'delta' =&gt; 'some-delta',
  'cache' =&gt; DRUPAL_CACHE_GLOBAL,
);
print _block_get_cache_id($fakeblock);


On a multilingual site, the fragment should print something like:


  some-module:some-delta:bartik:en