Tranlsation of Frontpage
Home › Forums › Free Theme Support › Asteria Lite › Tranlsation of Frontpage
-
#152619
Saad
On May 25, 2014 at 11:05 pmHi towfiqi,
First of all excellent work with the theme. Its really easy to use and very nice. I just had one question. I wanted to translate the frontpage. I’m using the plugin polylang. It seems that the only way possible in that is to have the homepage set to a static page and then having two language versions of it. But how can I have two versions of your front page with the blocks and the slider and everything?
Thanks
#153140On May 26, 2014 at 9:19 pmopen up functions.php and add this:
// [polylang lang="en"]English[/polylang][polylang lang="sp"]Spanish[/polylang] function polylang_shortcode($atts, $content = null) { if (empty($content)) return ''; extract( shortcode_atts( array('lang' => ''), $atts ) ); if (empty($lang)) return "<h3>You must specify 'lang' using shortcode: polylang</h3>"; return ($lang == pll_current_language()) ? $content : ''; } add_shortcode('polylang', 'polylang_shortcode');
before this:
//Asteria Site title
Then you can use this shortcode to in the welcome text box and blocks:
[polylang lang="en"]My English Text[/polylang][polylang lang="sp"]My Spanish Text[/polylang]
#225144
Admin KPasapp
On August 17, 2014 at 3:45 amThere is a small error in the code (see below), but after correction, it still doesn’t work for the slides and for the block titles. It works for Welcome text and block content.
Should another shortcode be used in titles & slides?
You can see the issue here: http://eventodos.com/test1/en/
Please note that shortcode was applied only to 2nd slide, welcome text and block 1, 2 & 3Another issue:
How blocks url should be managed for English and Spanish urls?The correct code is:
// [polylang lang=”en”]English[/polylang][polylang lang=”es”]Español[/polylang]
function polylang_shortcode($atts, $content = null)
{
if (empty($content))
return ”;
extract( shortcode_atts( array(‘lang’ => ”), $atts ) );
if (empty($lang))
return “<h3>You must specify ‘lang’ using shortcode: polylang</h3>”;return ($lang == pll_current_language()) ? $content : ”;
}
add_shortcode(‘polylang’, ‘polylang_shortcode’);and the shortcode to be used in the welcome text box and blocks:
[polylang lang=”en”]My English Text[/polylang][polylang lang=”es”]My Spanish Text[/polylang]
It probably doesn’t matter whether we use es or sp for Spanish, but it is a good idea to follow international standards.#227064On August 18, 2014 at 10:38 pmOpen up nivo.php and replace this line(appear multiple times):
<?php echo $arr['re_text_field_id']; ?>
with this:
<?php echo do_shortcode($arr['re_text_field_id']); ?>
and then open up content-blocks.php and replace these lines:
<?php echo $data['block1_text_id']; ?> <?php echo $data['block2_text_id']; ?> <?php echo $data['block3_text_id']; ?> <?php echo $data['block4_text_id']; ?>
with these:
<?php echo do_shortcode($data['block1_text_id']); ?> <?php echo do_shortcode($data['block2_text_id']); ?> <?php echo do_shortcode($data['block3_text_id']); ?> <?php echo do_shortcode($data['block4_text_id']); ?>
#227351
Admin Kpasapp
On August 19, 2014 at 4:11 amThank you.
Blocks are now bilingual and slides too. I still need to chekc urls. When I replaced all
<?php echo $arr[‘re_text_field_id’]; ?>
with
<?php echo do_shortcode($arr[‘re_text_field_id’]); ?>
It crashed at first. Then I only replaced
<h3 class=”entry-title”>href=”<?php echo $arr[‘slide_url’]; ?>”<?php } ?>><?php echo do_shortcode($arr[‘slide_title’]); ?></h3>
<?php echo do_shortcode($arr[‘slide_description’]); ?>Which made title and description multilingual.
#228086On August 19, 2014 at 5:46 pmopen up nivo.php and replace:
<?php echo $arr['slide_url']; ?>
with this:
<?php echo do_shortcode($arr['slide_url']); ?>
#277878
Joris
On September 25, 2014 at 1:23 amHi Guys,
I have tried the 2 solutions offered here and none of them was successful >> Both solutions ended up with an error code.
Thanks for your help,
Joris
#281174On September 26, 2014 at 7:29 pmJoris, what are you trying to achieve exactly?
#281841
joris
On September 27, 2014 at 3:44 amI would like to be able to translate the blocks and the welcome text of the homepage
#293094
Martie
On October 3, 2014 at 6:01 pmI would like to be able to translate the blocks and the welcome text of the homepage. I can’t seem to get to them. Can you instruct me as to how?
#301972On October 8, 2014 at 8:34 pmJoris does your content-welcome-text.php contains this:
<?php echo do_shortcode($asteria['welcm_textarea_id']); ?>
if it does, you can add this to your welcome text field from the theme options page to translate with polylang.
[polylang lang="en"]My English Text[/polylang][polylang lang="sp"]My Spanish Text[/polylang]
#304648
Joris
On October 10, 2014 at 1:15 amHi,
yes it does…
I copied the line into the welcome text field in the “text” (not the visual) part and it just rendered exactly “as is” on the website… (Sorry I am no specialist).
Thanks for providing more detailed information,
Joris
#309785On October 12, 2014 at 5:58 amdid you folllow this step:
#619320On July 30, 2016 at 3:09 pmHi there!
All information here is really useful Towfqi. Thanks also to Kpasapp for the tip about “sp” and “es”. I’m really happy with my pro version, really recommendable to you all.
I found some limitations to edit the Call to action with the do_shortcode thing. I only get to make it work in the button but not in the editable text.
Please Towfqui can you add some light on this? Thank you again.
<?php global $asteria;?> <?php $callaction = $asteria['home_sort_id']; if(!empty($callaction['call-to-action'])){ ?> <!--Call to Action START--> <div class="center"> <div class="home_action"> <div class="home_action_left"><?php echo $asteria['call_textarea_id']; ?></div> <div class="home_action_right"><div class="home_action_button_wrap"><div class="home_action_button"><a <?php if (!empty ($asteria['call_url_id'])) { ?>href="<?php echo do_shortcode($asteria['call_url_id']); ?>"<?php } ?>><?php echo do_shortcode($asteria['call_text_id']); ?></a></div></div></div> </div> </div> <!--Call to Action END--> <?php } ?>
You must be logged in to reply to this topic.