[Resolved] hard-coded text in the home page. Theme Customizr

Home Support English Support [Resolved] hard-coded text in the home page. Theme Customizr

This topic contains 8 replies, has 2 voices, and was last updated by  ornelaC 8 months ago. The support staff assigned to this topic is andreas.n.

Author Posts
Author Posts
January 21, 2014 at 8:51 am #324651

ornelaC

Hello

I have a short text hard-coded in my home page of my website (yellowbridge.eu) with theme Customizr.

the code is:
<br>
<?php if(is_home() && !is_paged()):?><div align="center">
<span style="font-size: large;">Yellow Bridge is an international knowledge center that inspires <br> and supports small and medium organizations
to improve their performance through sustainability.<br></span></div><?php endif;?>

How can I make sure that this text shows up in the different languages? I don't see under String Translation.

Thank you very much for your help

January 21, 2014 at 12:08 pm #324886

andreas.n
Forum moderator

Hello Ornela,

True, if the code is like this it wont appear under "WPML > String Translation". It needs to be wrapped into a gettext call – like __('text', 'text-domain').

Please try this:

1) Adjust the code to this –> http://pastebin.com/t9jcB1PW

– The %s is the placeholder for <br/>.
– [name of your text domain] is not known to me – could you asked the author for it?

2) Then head over to "WPML > Theme- and Plugins Localization"
> choose "Translate by WPML"
> rescan the strings in the theme, you should see an extra section for it

Does the text then appear under "WPML > String Translation" ?
Lets hope :-)


http://wpml.org/documentation/getting-started-guide/theme-localization/
http://de1.php.net/sprintf

January 23, 2014 at 9:32 am #326323

ornelaC

Thank you so much! Aparently [name of your text domain] should be customizr (which is the name of the theme.
However, when I replace this code for the one I had, the text doesn't show up anymore (not even in the original language) and I don't see it under the strings.

Please see code if I am doing something wrong:

1) I deleted the code I had:

<br>
<?php if(is_home() && !is_paged()):?><div align="center">
<span style="font-size: large;">Yellow Bridge is an international knowledge center that inspires <br> and supports small and medium organizations
to improve their performance through sustainability.<br></span></div><?php endif;?>

2) and introduced this one instead:

<br/>
<?php if(is_home() && !is_paged()):?><div align="center">
<span style="font-size: large;">
<?php
$line_break = "<br/>";
sprintf( __('Yellow Bridge is an international knowledge center that inspires %s and supports small and medium organizations
to improve their performance through sustainability.', customizr ), $line_break );
?>

3) please see that I wrote customizr without [ ] . I tried writing in between [] but the website doesn't show up at all then… I am doing this in the index.php file.

Your help is very much appreciated

January 23, 2014 at 11:28 am #326452

andreas.n
Forum moderator

Hello Ornela,

Must be some small detail – in which line of the index.php did you add your code?
–> http://pastebin.com/gewXAJyT
Have the theme installed over here, I can check then.

January 23, 2014 at 11:45 am #326472

ornelaC

this is how I have my index

http://pastebin.com/VaqGg4Vk

January 23, 2014 at 1:10 pm #326545

andreas.n
Forum moderator

Thanks!

Good – please adjust the code to http://pastebin.com/KqRRGwzQ
and then..
> scan the theme for new strings –> see screenshot
> translate the strings under "WPML > String Translation"

Does it show then?

If not..
Would you mind then providing us with credentials for your website and we have a closer look at the settings? For this purpose you should see a protected webform all they way down here in this thread. (it asks first for "Backup + Legal disclaimer")
Thanks in advance!

January 23, 2014 at 2:06 pm #326576

ornelaC

It doesn't work :(
I am making a back up now.

Something very weird just happened. One of the pages that was translated doesn't work anymore.
http://www.yellowbridge.eu/nl/duurzaam-inspireren/
It is very strange. everything was fine and now suddenly it doesn;t work. When you click on the menu or even if you go to the direct link, it just stays on the home page and the flags also dont show up anymore!
Do you have any idea what could have happened?
www.

January 24, 2014 at 8:57 am #326965

andreas.n
Forum moderator

Hello Ornela,

This new problem you mention sounds actually like a bug our developers working on right now (with high pressure) – could you open a new thread for that please?
Makes passing it on to others easier.

The hard-coded string, bit solution resistant. I noticed actually the very same problem over here as well . But I think it can be solved with our API function "icl_translate":

$name 		= 'Yellow Bridge';
$original_t 	= 'Yellow Bridge is an international knowledge center that inspires <br> and supports small and medium organizations to improve their performance through sustainability.';
echo $string 	= function_exists('icl_translate') ? icl_translate('customizr',$name,$original_t) : $original_t;

> please replace your index.php file with this new version -> http://pastebin.com/zU3a1V1X
> translate the text in "WPML > String Translation"
> translation should hopefully show, in my test installation it works now

January 24, 2014 at 9:17 am #326976

ornelaC

Hello Andreas
IT WORKS!! You can't imagine how happy I am. I am making a small dance here.

About the new problem, it is old now. I created a new page and translated it all over again. Had to find a solution fast.

I am very very grateful for your help.

Have a good day!

You must be logged in to reply to this topic.