Translating Block Contents
Although internally nodes and blocks are constructed differently, the module makes their translation appear the same.
Blocks will appear in the Translation Dashboard just like all other content types. Behind the scenes, Translation Management will fetch the strings created by the Drupal blocks and return the translated contents as string translations.
Drupal's i18n module can translate block contents.
To display blocks in multiple languages, you can use one of these approaches:
- Creating a different block for each language.
- Using string localization
When you create a block, you can choose to assign it to a specific language or to all languages and use string translation.
Method 1 - different blocks per language
Select a unique language for the block and indicate which nodes to display it for. You should select only nodes that are written in the same language as the block.
Then, create similar blocks in other languages and enable them for the nodes in those languages.
This process will keep complete isolation between blocks in different languages. They can be translations of each other, but can also contain completely independent contents. Drupal and i18n don't offer any facilities for synchronizing between block contents in different languages.
Method 2 - string localization
Drupal can translate strings from English to other languages (currently, there is no solution for translating from any language other than English). You can tell Drupal to handle the title and contents of blocks as strings and look for translations using Drupal's string translation mechanism.
When a block is being displayed in a different language, Drupal will look up the title and body of the block to see if there is a string translation of the title and body. If they are available the translation will be displayed otherwise it will display the original text.
To use this method set the block language to "All languages (Translatable)" while creating or editing a block.
NOTE: An important point when using this method is that the default language should be English. Drupal localizes these strings with the t() function, meant to be called whenever a module outputs an English text string.
Here is an example. We'll create a new block and translate its strings.
Create the block and set to 'All languages (Translatable)'
Choose where the block is displayed
We'll display this block in the right sidebar. The display position doesn't really matter and the block doesn't have to be displayed in order to be translated.
Which now shows as:
Switching to Spanish shows the block visible but with no translation:
Manually entering translation for the block contents
The strings for the title and the body are translated using the translate interface.
Go to /admin/build/translate/search and look for the strings used in the block.
Click on "Edit" and enter the translation.
Repeat for the body of the block searching for some text in the body.