Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] I18N - sidebar translation
#1
Hi Smile

I created a site in two languages, default is Czech and secondary is English.
Everything works fine except custom permalink structure (never mind, I'll try to fix that later again) and also sidebar translation.

I was trying to find some information how to make it work and I didn't find the answer.

What my sidebar does is that...
1) it shows a short and simple contact page with a phone number and a company name (editable in GetSimple pages tab) in the upper part of the sidebar
2) and it shows 3 recent News Manager posts with time and 250 characters of the text.
You can see how it looks and is supposed look here:
[Image: 73o5e1.png]

However, after switching to English, the sidebar stays in the Czech lang (the rest of the page is translated correctly).

This is my sidebar code:
Code:
<div class="panel">    
  <?php getPageContent('rychly-kontakt'); ?>  
</div>

<div class="panelVypisClanku">
  <p><strong>Nejnovější články</strong></p>
    
    <?php nm_set_custom_maxposts(3) ?>
    
    <?php nm_set_custom_excerpt(250) ?>
      
    <?php nm_custom_display_recent('
      <div class="my_recent_post">
        <h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
        <span class="my_excerpt_date">{{ post_date }}</span>
      <span class="my_excerpt">{{ post_excerpt }}</span>
    </div>
    '); ?>       
</div>

I read some information that I should use components. As long as the components are PHP themselves, I can't put the php News Manager functions into the components. I tried to put them there without the <?php ?> tags, without succes. I also tried to put it there directly in the .xml file, also without succes.
About the upper part of the sidebar, I could use components for that easily but it wouldn't be editable in the administration's Page tab.

What I would love to know is how to let the whole sidebar be translated when switching the site language?
If it has to be using components, I don't mind, better some solution than none.

Thanks, Tom.
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
#2
I think that you should use get_i18n_content instead of getPageContent, see here:
http://mvlcek.bplaced.net/get-simple/i18n:en/
in Language dependent Content -> Pages

As for the short text (Nejnovější články), see (same link above):
Language dependent Content -> Conditions

(I forgot) ...or you could use get_i18n_component and create two (almost identical) sidebar components, one for each language.

PS I don't understand why the News Manager Addons functions didn't work for you in component. They should (it's how I use them). BTW you should add a ; before the closing ?>
Reply
#3
(2013-04-18, 04:01:45)Carlos Wrote: I think that you should use get_i18n_content instead of getPageContent, see here:
http://mvlcek.bplaced.net/get-simple/i18n:en/
in Language dependent Content -> Pages

As for the short text (Nejnovější články), see (same link above):
Language dependent Content -> Conditions

(I forgot) ...or you could use get_i18n_component and create two (almost identical) sidebar components, one for each language.

PS I don't understand why the News Manager Addons functions didn't work for you in component. They should (it's how I use them). BTW you should add a ; before the closing ?>
Thank you Carlos. I have already seen the page many times, however, I just didn't use that functions...

So the get_i18n_content solved my upper part of the sidebar Smile



However, there are still problems in the lower part.

How did you manage to get the component working with nested functions?

Look how I tried to do it. The second component is different because I wanted you to see both ways how I tried to include the functions inside of the component.
[Image: 2uq1yiu.png]
It just didn't work, the div on my site was empty like <div></div>.





I also tried with the same method as in the upper part of the sidebar, however, without success - the CKEditor always added <!-- --> around PHP tags; even editing .xml files didn't work for some reason (html entities I think).

In the template was
Code:
<div class="panelVypisClanku">
  <?php get_i18n_content('bocni-panel-nejnovejsi-clanky'); ?>          
</div>

After putting this code into a page's source code
Code:
<p><strong>Nejnovější články</strong></p>
    
    <?php nm_set_custom_maxposts(3) ?>
    <?php nm_set_custom_excerpt(250) ?>
    <?php nm_custom_display_recent('
      <div class="my_recent_post">
        <h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
        <span class="my_excerpt_date">{{ post_date }}</span>
      <span class="my_excerpt">{{ post_excerpt }}</span>
    </div>
    '); ?>
and saving the page, it transformed into this
Code:
<p>
    <strong>Nejnovější články</strong></p>
<!--?php nm_set_custom_maxposts(3) ?--><!--?php nm_set_custom_excerpt(250) ?--><!--?php nm_custom_display_recent('
      <div class="my_recent_post"-->
<h4>
    <a href="{{ post_link }}">{{ post_title }}</a></h4>
<p>
    <span class="my_excerpt_date">{{ post_date }}</span> <span class="my_excerpt">{{ post_excerpt }}</span> '); ?&gt;</p>
which is useless Smile





I worked it out by using a condition in the lower part of the sidebar in my template. It works like a charm now, thanks for the tip. I don't think this bar needs to be editable as the upper one.
Code:
<div class="panel">    
  <?php get_i18n_content('rychly-kontakt'); ?>  
</div>

<div class="panelVypisClanku">
    <?php if ($language == 'cs') { ?><p><strong>Nejnovější články</strong></p><?php } ?>
    <?php if ($language == 'en') { ?><p><strong>Latest posts</strong></p><?php } ?>
    
    <?php nm_set_custom_maxposts(3) ?>
    
    <?php nm_set_custom_excerpt(250) ?>
      
    <?php nm_custom_display_recent('
      <div class="my_recent_post">
        <h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
        <span class="my_excerpt_date">{{ post_date }}</span>
      <span class="my_excerpt">{{ post_excerpt }}</span>
    </div>
    '); ?>       
</div>




But there's still a bug in me head why it haven't worked with both the components and/or the pages... don't you know?


Either way, thanks a lot Carlos Smile you always know somehow.
And sorry for my extra-long post as usually.
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
#4
Sorry for the short/quick reply, still not much time available. Just two comments:

1. The second component (panelvypisclanku_en) is incorrect, you have to use <?php ... ?> tags in components to use PHP code.

2. You cannot use PHP code in GS pages. You can do however in components and template files.
Reply
#5
(2013-04-18, 06:27:29)Carlos Wrote: Sorry for the short/quick reply, still not much time available. Just two comments:

1. The second component (panelvypisclanku_en) is incorrect, you have to use <?php ... ?> tags in components to use PHP code.

2. You cannot use PHP code in GS pages. You can do however in components and template files.
Your hint is enough, thank you Smile it works perfectly now with both the components or the condition. I don't really know why it didn't last time, maybe I have had forgotten some character or the I18N "tag" in the function.

Anyway, thanks, it works Smile

Code:
<div class="panel">    
  <?php get_i18n_content('rychly-kontakt'); ?>  
</div>

<div class="panelVypisClanku">  
    <?php if ($language == 'cs') { ?><p><strong>Nejnovější články</strong></p><?php } ?>
    <?php if ($language == 'en') { ?><p><strong>Latest posts</strong></p><?php } ?>
    
    <?php nm_set_custom_maxposts(3) ?>
    
    <?php nm_set_custom_excerpt(250) ?>
      
    <?php nm_custom_display_recent('
      <div class="my_recent_post">
        <h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
        <span class="my_excerpt_date">{{ post_date }}</span>
      <span class="my_excerpt">{{ post_excerpt }}</span>
    </div>
    '); ?>
    
  <!-- or, in the admin panel => Themes => Edit blocks/components; 2 components needed - name and name_en :)
   <?php get_i18n_component('panelvypisclanku'); ?> -->
         
</div>

I had better did a comment in my template to not forget the options Smile

Thanks once again.
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply




Users browsing this thread: 1 Guest(s)