Closed (duplicate)
Project:
Panels
Version:
6.x-3.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Sep 2009 at 20:59 UTC
Updated:
23 Jul 2012 at 13:25 UTC
Jump to comment: Most recent file
Comments
Comment #1
druojajay commentedHere's my rather hacky workaround for now. In page.tpl.php, I replaced:
print $content;With:
...where "What's New" and the like are the pane titles I wanted to translate. Would love to know if there's a better way, though.
Comment #2
dasjoi have this problem as well. would be great, if panels added its panel-page-title-overrides to translation as for example views does it for block titles...
the hack stated above might work, but it's kind of dirty ;)
Comment #3
Ghostthinker commentedHi,
I have the same problem. The i18n module is great, just like panels. I think the problem with this is, that the use of the translation function t() in a field with dynamic content (user generated text, just like "empty text" of views) would probably spam the string table? I don't know.
I had a quick look over the (massiv)panels module and was able to t() the titel of panes, not of panles
. Maybe it's a cache thing, maybe the related stuff is in ctools, I again don't know. Anyone with more info about that?
Comment #4
merlinofchaos commentedUnlike Views, Panels actually has no mechanism at all for translation. This is something that we need to consider and figure out how to architect in. It's something that will probably happen after the Views 3 translation system is complete. We can then try to rework Panels to utilize the same architecture so that translators have a consistent experience.
Comment #5
zilverdistel commentedI altered the folowing code (panels.module, line 1030 starting with $vars['title'])
to
and my problem is fixed (for now) ...
Comment #6
blueblade commentedsame problem here...
Comment #7
ducdebreme commentedFound a solution: there are some panel hooks available.
The translation can be done by implementing hook_ctools_context_converter_alter()
Mind the call by reference to value
Comment #8
blueblade commentedHi ducdebreme,
What a great news! how do you implement that tho?
BB
Comment #9
iamjon commentedsubscribing
Comment #10
iamjon commentedI'm not too sure which way is the best to do this, here is my solution.
I exported all my panels, panes and mini panels to code using the bulk export module. I then searched for the specific titles that needed translating.
I first tried wrapping the text title in the t() function so
'override_title_text' => 'Some Text', became 'override_title_text' => t('Some Text'),
Unfortunately that did not work. (At least it did not work instantly)
What did work was at the beginning of the the mymodule_default_page_manager function that created the text, I declared a variable which was string wrapped in the t() function.
function mymodule_default_page_manager_pages() {
$somevarible= t('Some Text');
....
}
Searching for the string worked instantly and I was able to translate.
The reason I chose to go this route was because it didn't involve hacking the module. I would love if someone could let us know which of the above workarounds is recommended until this issue is fixed.
Comment #11
merlinofchaos commentedExporting and wrapping in t() is a lovely workaround until we can get a proper translation method into the exports.
Comment #12
iamjon commentedThank you so much for the response. Can we mark this as postponed?
Comment #13
nhck commentedCan you provide a little longer example iamjon, ducdebreme - i don't really understand how you implemented this?
Comment #14
paymentadmin commentedHello, here is my recipe:
I'm using token + page title modules, and I set in "/admin/content/page_title" [page-title] for all pages
Then I made some changes in panels include file "modules/panels/includes/display-render.inc":
Here it is:
I changed the way of title rendering for PANELS_TITLE_PANE. It returns NULL.
So I set "title type: from pane" for any panels page. And I created two content-panes with PHP-Filter and with language rules (One for English, and one for Russian).
In english pane I wrote:
And I've got needed title. And the same way for russian pane:
Good luck!
Comment #15
iamjon commentednhck
I used the bulk exporter module .
Basically the module allows you to take all your panels and put them into a custom module of your own.
Go to admin/build/bulkexport
It gives you a list of all your panels you can either select the ones that need to be translated or select all
It also asks you for a module name. Give it a name. For the rest of the example we are going to use "yourmodule"
When you click the export button you are taken to a new screen which tells you what to put into the various module files
Go to sites/all/modules and create a folder with the module name you created earlier ("yourmodule").
In it you need to create 4 files:
yourmodule.info, yourmodule.module, yourmodule.panels_default.inc, yourmodule.pages_default.inc
You copy the contents of the the four text areas into the four files.
Go to admin/build/modules/list turn on the module just made.
Clear the caches And go to /admin/build/pages
If everything worked well you will see overridden instead of normal. This means that the panel exists in code but the system is using the version that is in the db.
Click revert (Please back up your db before) and the panel will switch to "in code".
In yourmodule.panels_default.inc abd yourmodule.pages_default.inc search for the specific strings you want translated and wrap the strings in a t() function.
I needed 'override_title_text' => 'Some Text', to become 'override_title_text' => t('Some Text'), and $display->title = 'Articles'; to be $display->title = t('Articles');
Once you've wrapped them in the t() function
Clear your cache again and go to admin/build/translate/search if everything works you can find the string there and translate it with the system
Good luck
Comment #16
sagannotcarl commentedSubscribing. Thanks for the workaround.
@iamjon: the Features module is also handy for exporting panels (in addition to so much more!)
Comment #17
Vote_Sizing_Steve commentedSubscribing.
Comment #18
drewish commentedsubscribing.
Comment #19
henrijs.seso commentedsubscribing. cheering.
Comment #20
fnikola commentedHi iamjon,
Thanks for the detailed instructions. I'm having an issue when I export the panel pages I only see 3 text areas (yourmodule.info, yourmodule.module, yourmodule.pages_default.inc) - the yourmodule.panels_default.inc is not created so I have no code to place in that file and therefore did not include that file in the yourmodule folder. I went ahead with the rest of the steps (clear cache, revert, wrap the page title in the t() function, clear the cache), but I do not see the page titles in the translation.
I'm trying to determine what is missing in the yourmodule.panels_default.inc file so I can add it.
Thanks.
Comment #21
iamjon commentedhi fnikola,
The latest version of panels and bulk exporter will give you another text area called pipelines.
I think the reason you have three is because you don't have any mini panels.
I tried on a site that didn't have a mini panels and I also had three (four if you include pipelines).
Export everything to code.
Installl/turn on the module.
To check if the module is catching once it's on check sure that all your pages have been switched to overridden instead of normal (admin/build/pages/list) , revert them to code (click edit revert...just make sure to backup your db before)
Once this is done, search for the string your want to translate in your editor, (I just search for 'title') and wrap it in t(), clear caches, and hopefully it will work.
Good luck.
Comment #22
elioshI found another solution, very quick to implement:
this way I can change PANE title but not the whole PANEL title :-|
Comment #23
minghui.yu commentedHow about this:
Create a View that contains the tile (this view can contain argument to choose language on the fly).
Instead of directly putting Node:Title in your panels, use the title from the View to put it in panel.
Comment #24
Vote_Sizing_Steve commentedMy developer came up with this solution - which I added to my sites/all/themes/{My Theme}/panels/panels-pane.tpl.php:
Comment #25
perceptum commentedThanks. This worked very well. Appreciate the hint!
Bryan
Comment #26
perceptum commentedJust a side note... once you pass the strings through t() and start looking for them in the translate interface UI - dont forget the search is case sensitive. I spent a little while looking for the strings, thinking the template wasnt working ... but my search was in lower case and the string was in upper case.
HTH
Comment #27
joachim commentedAFAIK, using t() for user or admin-input strings is wrong, though I'm not quite sure what you're meant to do instead.
Comment #28
bibo commentedEven if the solution of #24 is dirty, it's the easiest way that actually works no matter the pane source (block, view, quicktab etc).
This method easily leads to re-translating the same strings like: original => custom => (custom treated as original) => custom, which will get messy and confusing really fast. Not to mention the unnecessary localization string duplicates, and mixups. Some pane titles are translated through their sources (like views), and we don't want to re-translate these.
I avoided this problem by translating only titles that I've overridden in the panel settings, as I noticed overridden titles just don't get translated. I took the panels-pane.tpl.php template approach, but changed:
<h2 class="pane-title"><?php print t($title); ?></h2>.. to this:
You could also make sure it doesnt get mixed up with other identical strings, by replacing the second line with:
$title = substr(t('Panel:'. $title), 6);This is still dirty, but it's easy and it works.
Afaik the non-dirty way would be using tt(), or rather tt() through a wrapper, in a custom module. Something like this. #7 does it by lending the implementation of the taxonomy-module. I believe it would make sense for panels use a similar approach like taxonomy or notifications (for multilingual pane titles).
Comment #29
moritzz commented@joachim In D6 "admin-input strings" should be translated though i18n_strings to provide "context" so translation do not get lost every time you change the source string (i.e. the string you enter in pannels admin interface). Implementing this directly in panels would built up another dependency, and it might therefore be better to provide - if possible - a separate i18n_panels (sub-)module.
Therefore: Subscribing as well.
Comment #30
Rhicreate commentedFor those who need a quick fix for translating Panel titles, you could try this... (probably classed as dirty in this issue, and by no means a permanent solution!)
In the panels where I need a translation of a title I have set them as "No Title" then added a custom block with input type PHP code as follows -
and translated the string in the interface. I presume you could also replace %term:name with other title substitutions...
I'm not sure if this will work in every instance, my panels are receiving an argument of Taxonomy Term ID from the URL, so I only have a couple of panel types to update in this way, it may not be fun to implement if your site has a lot of different panels!
Comment #31
xamountIn my pane (which happens to be "new custom content"), I just put this php line at the top of my content:
Don't forget to set your input format for the pane to be PHP
Comment #32
Rhicreate commentedA much better semantic solution! Can't seem to get to work with an argument though... E.g. for all taxonomy term pages? At least not with this code:
drupal_set_title(t('%term:name'));so guessing that's wrong... what value can I use to put the current term in that translatable title please?
**update** Know I'm not being completely stupid now, because I can't even get a basic string to print out in panels with the set_title function... wonder if it's because Panels has already dealt with this, and it won't reset again.
Comment #33
zilverdistel commentedThe method in #24 could be improved by using a template_preprocess function. Something like
should also work. Less code, less redundancy, and it wouldn't be in the way of future changes in panels templates.
Haven't tried it though, but imho, it should work.
If you want to do this in a module, you would actualy use hook_theme_registry_alter() to add a preproccess function to the theme hook 'panels_pane'.
If this works, we could instead use tt() or even i18n_strings() instead of t(), as pointed out by moritzz in #29.
Comment #34
lestu commentedThis is very good advice! :)
Actually, for my case it was even easier.
All I had to do was set the panel title to manually, leave the title field empty and create a custom content:
Be sure to wrap that text in t().
The title of the panel is now translatable even without a language based visibility rule.
Thanks,
Lestu
Comment #35
henrijs.seso commentedAny plans on actually fixing this? Maybe at least in 7x version?
Comment #36
emattias commentedHere's a patch that adds the t function to the get_title function in panels.module
Comment #37
zilverdistel commented@emattias: These titles are dynamic strings and should not be run through the t() function. See http://api.drupal.org/api/drupal/includes--common.inc/function/t/6 for more information.
Comment #38
emattias commented@zilverdistel: Hmm, ok but how do I then make the titles translatable?
Comment #39
zilverdistel commented@emattias: maybe this post may be of help for you: http://groups.drupal.org/node/87864#comment-276909.
Comment #40
heyyo commentedThe template overriding or the modification in template.php doesn't work anymore on my website on taxonomy override with Panels. I have no problem with Title in Node ovveride.
I'm using panels 6.x-3.9.
Any idea ?
Comment #41
Letharion commentedClosing this as there is now a suggested patch over here: #1179034: Translatable panel titles: Implement i18n_strings.
Comment #42
Jérôme Brunel commentedHi,
You just have to modify panels-pane.tpl.php in your Panel module directory/templates: modify print $title; by print t($title); and this will add your pane titles to "translate interface".