can I change block title depending on locale, for module-generated blocks?
I still can't get the way how localizerblock works at all - you can select one locale and the block will be shown only in that locale? Does it mean that I need to create 5 same blocks in different languages if I have 5 locales?
Sorry for stupid questions :)
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | module_3.patch | 5.42 KB | restyler |
| #18 | block_11.patch | 5.42 KB | restyler |
| #4 | localizer_sitemap.png | 15 KB | restyler |
Comments
Comment #1
Roberto Gerola commented> Does it mean that I need to create 5 same blocks in different languages if I have 5 locales?
Exactly.
It works in a similar way as for nodes.
the only difference is that it isn't a relation between the block translations.
Comment #2
restyler commentedDoes it mean that I can't change the title of, for example, 'user login' block?
Comment #3
Roberto Gerola commentedThis is out of my control.
Have you tried to see if the title appears in the localization strings ?
It should be possible to provide a translation for it there.
Comment #4
restyler commentedIn Drupal5 you have an option to change block header of any block, e.g. in admin/build/block/configure/user/0 you can override default title of 'User login' block. I was wondering if there is any way to localize this type of user input.
My next question: I've ported 'site_map' to D5 yesterday, and I've installed it on my website to show all site menus. I have 'ru' and 'eng' locales. My navigation menu is translated, but sitemap shows UNtrunslated menu titles and translated menu elements. I'm not sure why it is happening so, the code to create sitemap menu is:
is it a problem of localizer or of a sitemap?
Comment #5
Roberto Gerola commentedThe translation of menus is done through the hook_menu.
I suspect that _site_map_menu_tree($mid, $menu)
make an indirect call to this hook somewhere.
You could simply call the translation API for the title :
$translation = localizer_translatemenuitem($mid);
$title = $translation->title.
Let me know,
Comment #6
restyler commentedThanks for your help.
I've fixed that by
but I've tried to find the indirect call to hook_menu and I didn't find it... I can't understand why all menu elements are _translated_, and title is not.
Comment #7
restyler commentedI've created a block, changed it locale to 'english'.. but I see it on russian locale too.
I've tried to debug localizerblock_db_rewrite_sql():
Comment #8
Roberto Gerola commentedSee here : http://drupal.org/node/111738
The first patch didn't work properly.
Comment #9
restyler commentedI've patched block.module, now db rewriting works but multilingual blocks still are showed on all languages...
SQL that the rewriting function gets:
returns:
Comment #10
Roberto Gerola commented> multilingual blocks still are showed on all languages
What are multilingual blocks for you ?
Have you can see in the SQL localizer shows also the block without
a locale. Is this the problem ?
Comment #11
restyler commentedI've tried simple blocks, menu blocks... for simple user created blocks with 'eng' or 'ru' locale the localizerblock doesn't work at all. For menu blocks it works strange, it hides my website navigation on 'eng' locale, though I've set 'any' locale in block settings.
Comment #12
Roberto Gerola commented> for simple user created blocks with 'eng' or 'ru' locale the localizerblock doesn't work at all.
Ok, it could be. There is another function to patch to filter also user blocks.
>For menu blocks it works strange, it hides my website navigation on 'eng' locale, though I've set 'any' locale in block settings.
Ok. I make some other tests.
Comment #13
restyler commentedI've rewritten localizerblock.module to work in 'localizervars way', I mean every block have multilingual title and block of 'block.module' (box) also have multilingual body. I had to patch block.module to make it work, so I'm not sure if anyone need it :) I'll test it a bit more and upload tomorrow as a patch.
Comment #14
Roberto Gerola commentedVery good ! Thank you !
Post it here or send it to me by email, so I can integrate it.
At now we have 4 "features" that share in some way the same interface
for translation : variables, menus, taxonomy (to be modified) and blocks.
Your proposal to use the localizertranslation table to translate blocks is
a very good idea ! So we can avoid of storing multiple blocks in the database.
I'm not worried about the patch.
Taxonomy module has been patched a lot to work.
If possible we should use the same logic used in taxonomy.module to patch also block module,
with the use of the tobject method.
Comment #15
restyler commentedhttp://russianwebstudio.com/other/localizerblock-5.x-0.1-dev.rar
I've attached my version of block.module and patch against cvs version.
Comment #16
restyler commentedI'm not sure that this version of loc_blocks module can completely replace the old one. May be someone needs to hide some block on some locale, but I think he can use i18n_get_lang() in 'Page specific visibility settings' (Show if the following PHP code returns TRUE (PHP-mode, experts only).) + my version of loc_blocks to override titles and box bodies
Comment #17
Roberto Gerola commented>i18n_get_lang()
You shouldn't use this function.
It is called only to determine the language on the first access.
Use instead localizer_get_nodedefaultlocale();
I need to make some changes to your patch.
We can use the tobject function.
It seems to me that the patch is reversed.
The code to add is reported to delete.
Am I wrong ?
Comment #18
restyler commentedOk. In this case I need to change loc_profile and loc_vars too
Yes you are right :) I've attached correct patch
Comment #19
restyler commentedOk. In this case I need to change loc_profile and loc_vars too
Yes you are right :) I've attached correct patch
Comment #20
restyler commentedoops, double post. The last post has correct patch
Comment #21
Roberto Gerola commented> Use instead localizer_get_nodedefaultlocale();
I'm renaming this API, but don't mind, when I'll integrate your code
I'll change it.
It will become : localizer_get_contentdefaultlocale();
It is more correct, because it has to do with the content, and
not only with the nodes.
So we have uilocale and contentlocale in the methods.
Comment #22
Roberto Gerola commentedYour localizerblock implementation works for users provided blocks but not
for blocks provided by other modules as, for example, by menus.
I think I must add also this second feature,
as it was in my first implementation.
I see also the need to define a good and coherent interface user
for the translations.
Actually we have a mixed approach from you solutions, my original solution
and Ray's work.
It is correct that changing the language by the switching block is it possible
to translate the entries in variables, menu, taxonomy, block.
Probably it is the most user-friendly approach and it simplify the interface,
so I think I can remove my fieldsets and follow your example.
The only missing thing is a message to the user : "You are on the English/German/Russian/Italian version".
I'll put it in the description on the field at now.
I've decided to not change the naming scheme, at now.
The renaming is only postponed.
There is already a lot of work to do for the next release, and
naming conventions have an impact also on the db tables
names, as localizernode, localizeruser.
I prefer to be sure at 100% of the solution before changing
names everywhere.
Comment #23
restyler commentedMm, it works for me, I've tested it on block.module boxes and my website navigation menu.
I'm not sure that this approach will be ok for menu items - pretend that you need to translate 20 menu items on 4 languages.. huge amount of page reloads.
But, if we implement some kind of 'translation console' for mass translations, it would be ok.