In block configuration, there is a locale selection tab, but no translation tab. So, we only can use one language for block title, instead translate it depending currently selected language? I mean, I choose English in locale and input title, that title will be used for all language.

Am I wrong in using block translation? Do I miss some settings?

CommentFileSizeAuthor
#14 block-locale-0.patch528 bytesCybso

Comments

huayen’s picture

I read the document, which says that "Blocks can be associated with particular languages".

So, for block, we can not make it bilingual, right?

edinjapan’s picture

Your assessment is correct.
In the current implementation of Localizer, you can create a block, and then when you configure it, you can set a locale for display. The block will only display in the selected locale. The point of this feature is to let different blocks be displayed when different languages are set, not the same block with different languages.

So, a block can only be associated with one locale, and cannot be translated. If you need the same block content in another language, you will need to create another block in the other language and associate it with that locale.

huayen’s picture

[blockquote]you can create a block, and then when you configure it, you can set a locale for display. The block will only display in the selected locale.[blockquote]
I don't think the module works in this way. After I read your reply, I tried again, the block I configured to English locale still shows in Japanese locale...

edinjapan’s picture

Version: 5.x-1.x-dev » 5.x-1.7

Hi huayen,
I have re-verified that this is the way it should work. I'm not exactly sure why your troubles are occuring. Can you please check/try the following? (Although this issue was posted as regarding 5.x-1.x-dev,I have assumed you are using Drupal 5.1, Localizer 5.x-1.7. I have changed the related version on this issue to match this. Please change it back if it is incorrect.)

  1. Did you use the "patch" command to install the Localizer patches or just swap out the files with the ones provided by Localizer? I ask because Localizer 1.7 had Drupal 5.0 patch swapout files in it. I don't know that this would be the problem, but it is worth checking.
  2. Under Administer > Site building > Blocks, click the theme you are using for your site (if it is different from your Admin theme setting, be careful, as you will see different results in the admin screens than regular screens just because of this.) Look at all the blocks in the list. Are the correct ones enabled or disabled? You will need to have all blocks for all locales enabled with a position on the screen.
  3. For the sake of argument, for each block, click configure just to check an make sure the locale is set correctly. I've confused myself on this before because if you want a "translated block", the block has to show up twice on the same list but with different locales. (I have since started using different descriptions with a hint about the locale setting so that it is easier to tell the difference.)
  4. If you find no problems with the theme settings or locale settings above, try deleting the problem blocks and then recreating them. This may sound like overkill, but if a locale pointer is somehow messed up, this maybe the easiest way to get it in line again. Also, once you have recreated them, double check that locale setting!

Let me know what happens. If you want to take this offline, you can send me an email from my profile node. http://drupal.org/user/93820

huayen’s picture

Hello EdInJapan,

Thank you very much for the reply.

(1) I used patch command in installation.

I re-created blocks exactly according to (2) and (3), but still same problem. Now I have to use PHP return check to set the block visibility based on current locale.

Mini_me-1’s picture

I have the same issue. My blocks working exactly as written "In the current implementation of Localizer, you can create a block, and then when you configure it, you can set a locale for display. The block will only display in the selected locale. The point of this feature is to let different blocks be displayed when different languages are set, not the same block with different languages. So, a block can only be associated with one locale, and cannot be translated. If you need the same block content in another language, you will need to create another block in the other language and associate it with that locale."

Is it possible some how to make block title display according to selected language. Because I have blocks which are come from the view. These blocks have "More" link. And I have to create to completely same views but with different links. I think that it is not the best way to make block title translated :)

Is there some workaround?

huayen’s picture

Now it's working now after I switch to another theme.

However, I still prefer to use php code to define block title in following way:
----------------

global $locale;
if ($locale=='lang1') {

*****
} else if ($locale=='lang2') {
#####
}
----------------
This is much easier than defining two custom blocks.

However there are still some blocks coming with module installation (manage string in localization does not work for this case)

Roberto Gerola’s picture

I'll take a look t change the block translation mechanism.
Not using the localizerblock table but the localizertranslation
table instead and a translation interface similar to that implemented
for menu and taxonomy.

giorgosk’s picture

if "block title translation" is the only issue (as the title of the issue indicates)

all you need is wrap the block title in t()
in your block.tpl.php in your theme's folder

....
  <h2><?php print t($block->subject) ?></h2>
....

and then
after viewing the block so that t() functions flags the title for translation (<-IMPORTANT)
look in your "locale > translate strings" for the string to translate

Roberto Gerola’s picture

If we want translates only titles of the blocks, I need to patch the block.module.

sun’s picture

Assigned: Unassigned » sun

@roberto: Regarding #8, we've converted localizerblock to use the localizertranslation table already. Will be part of Localizer 2.x which we plan to commit within the next days.

@kongeo: Using t() for block titles is simply overkill.

Try this instead:

// block.module:137
    case 'view':
      $block = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid = %d', $delta));
      // Localizer support
      if (function_exists('tobject')) {
        $block = tobject('block', $delta, $block);
        $data['subject'] = $block->info;
      }
      $data['content'] = check_markup($block->body, $block->format, FALSE);
      return $data;
sun’s picture

Status: Active » Fixed

Please test the new version 2.x. Feel free to re-open this issue if it is not yet fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Cybso’s picture

StatusFileSize
new528 bytes

The changes as unified diff.