3

I am building a multilingual site using Drupal 7. I have used Views to generate a page, and in that page I have added a link in the view footer. The custom code that I use in my views footer is as below.

<?php <a href ="/blog-archieve">To blog archive</a> 

My problem is that I am using i18n module to translate the contents. In the translate interface I get the full above code, and as a result I lose my footer in views. Is there any way by which I can translate the "To blog archive" instead of the full code?

1
  • can't see your code, can you pastebin it somewhere. try putting "To blog archive" in the t() function and then have a translation for the string "To blog archive", since it passes through t() it will be translated.
    – Dipen
    Jun 7 '12 at 10:45
2

Try changing your footer to the following:

<?php
$link = l(t('To blog archive'), 'blog-archive');

print $link;
?>

References:

l();

t();

5
  • 1
    I think '/blog-archive' should probably be 'blog-archive'.
    – Andy
    Jun 7 '12 at 11:33
  • Thanks for your reply. But when i use this code in the footer region of my views, I get the code printed in the views page, not the "To blog archive".
    – user4081
    Jun 7 '12 at 11:50
  • @Slasengger you need to enable php.module and use the php filter in the Views footer.
    – Andy
    Jun 7 '12 at 12:05
  • ^this - I assumed you had it enabled already as you had an opening <php in your footer text.
    – Chapabu
    Jun 7 '12 at 12:09
  • Thanks a lot chapabu and andy:):) U both got me on the right track:):) the above code worked by enabling the php filter module.
    – user4081
    Jun 8 '12 at 6:17
1

If you want to avoid using the php filter and are ok with having the different translations all together, then you can use Language Sections. It uses a format like this:

=== es ===

This text will only be displayed when Spanish language is selected by the user.

=== fr ===

This text will only be displayed when French language is selected by the user.

=== others ===

This part will be displayed when the user's selected language is neither Spanish nor French, i.e. all other languages, and so might provide text in a common language such as English.

=== all ===

This part will be displayed for all languages.

You can also use Internationalization Views. It doesn't have a stable release for 7.x, but it does have over 4k sites reporting they're using the 7.x dev release.

(I'm afraid I have no personal experience with either.)

3
  • Thanks for ur reply andy. The above 2 options did not provide a solution:(
    – user4081
    Jun 7 '12 at 11:59
  • @Slasengger sorry to hear that :/ Can you be more specific as to the problems?
    – Andy
    Jun 7 '12 at 12:04
  • Chapabu's code solved the issue. Thanks for reminding me to enable the php filter:)
    – user4081
    Jun 8 '12 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy