Jump to content


Photo
- - - - -

Translate sections (iBox) using WPML

WPML iBox textBox

Best Answer radm , 24 February 2014 - 05:19 PM

Right! So, after a couple hours more digging around, I concluded the following:
 
1. with Polylang, it's possible to translate everything, but it requires creating separate pages for each translation
 That would be fine, but manually [re]creating the same template for each translation after each change was not ideal in my situation, so I gave up on Polylang and reverted to WPML.
 
2. WPML - after serious persuasion, it works; here's what I did:
 
a) duplicate whatever section you need, in your child-theme; if you already have content, copy-paste to overwrite the default implementation, otherwise, it's good to at least change the class name (NB: edit comments at top of the file accordingly)
 
B) use either _e($string, $domain) or __($string, $domain) [NB: double underscore] to register your strings (not exactly sure what actually happens here…). $string is what needs translating (doh!) and $domain is what group tit should fall under, such as 'pagelines' or 'myCustomThemeName' 
 
c) refresh the actual page in your browser (not the admin)
 
d) use WPML -> String Translation -> Save options and rescan strings
 
now, you should see your $domain under the 'Select strings within context: '  drop-down. If you don't, do not panic yet, just curse a little, take a deep breath and go to WPML -> Theme and plugins localization and spam the 'scan the theme for strings', then go back and repeat last step
 
If it still fails, you might want to create a class with fields as the string you're interested in and use it to spawn dummy objects. Not sure if this helps, but I did it this way, because I don't know exactly when the registration occurs...
 
In conclusion, I hope this will help someone else, despite it being a rather dirty solution. I'm going to settle with this until - hopefully - native Pagelines sections will do this by default. Alternatively, a hook solution would also be nice, but at least for iBox, none of the hooks share scope with the variables, so Hooker was useless for this…
 
Cheers!
Go to the full post


  • Please log in to reply
7 replies to this topic

#1 radm

radm

    Newbie

  • Members
  • Pip
  • 5 posts
  • Country: Country Flag

Posted 18 February 2014 - 09:09 AM

While there are no issues with translation of the page content and some of the sections (such as Hero and Highlight), I could not find any way of setting up multi-lingual content for iBoxes in my theme. I tried to use string translation in WPML, and despite finding the iBoxes content under "Translate texts in admin screens", no matter what I tried, the translation is not visible on the page.

 

I assume it might have something to do with the way iBox is implemented, but I am not sure what is the actual problem. Worst case scenario, I'd override iBox with a custom section, but first I need to know precisely why this happens. 

 

Other similar posts simply conclude that it doesn't work, but do not provide any satisfactory alternative, so if anybody has any idea, it would be greatly appreciated.



#2 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 18 February 2014 - 10:37 PM

Hi there, there are issues with WPML that the core team are aware of. Have you tried using Polylang? http://wordpress.org/plugins/polylang/ The developer team confirm this is 100% compatible with DMS and has been fully tested.



#3 radm

radm

    Newbie

  • Members
  • Pip
  • 5 posts
  • Country: Country Flag

Posted 24 February 2014 - 10:22 AM

Thanks, James, I'll look into it.

 

…though, I hope at some point, WPML will also be fully compatible.



#4 radm

radm

    Newbie

  • Members
  • Pip
  • 5 posts
  • Country: Country Flag

Posted 24 February 2014 - 01:28 PM

Well, a few hours later, I'm still struggling with getting polylang to translate sections created with Pagelines.

 

I might be missing something obvious, or just didn't find the right documentation on how to do this, so if you have any suggestions, it'd help me a great deal. All I need to do is get translations for tile and content of various sections I add to the template via drag'n'drop.



#5 radm

radm

    Newbie

  • Members
  • Pip
  • 5 posts
  • Country: Country Flag

Posted 24 February 2014 - 05:19 PM   Best Answer

Right! So, after a couple hours more digging around, I concluded the following:
 
1. with Polylang, it's possible to translate everything, but it requires creating separate pages for each translation
 That would be fine, but manually [re]creating the same template for each translation after each change was not ideal in my situation, so I gave up on Polylang and reverted to WPML.
 
2. WPML - after serious persuasion, it works; here's what I did:
 
a) duplicate whatever section you need, in your child-theme; if you already have content, copy-paste to overwrite the default implementation, otherwise, it's good to at least change the class name (NB: edit comments at top of the file accordingly)
 
B) use either _e($string, $domain) or __($string, $domain) [NB: double underscore] to register your strings (not exactly sure what actually happens here…). $string is what needs translating (doh!) and $domain is what group tit should fall under, such as 'pagelines' or 'myCustomThemeName' 
 
c) refresh the actual page in your browser (not the admin)
 
d) use WPML -> String Translation -> Save options and rescan strings
 
now, you should see your $domain under the 'Select strings within context: '  drop-down. If you don't, do not panic yet, just curse a little, take a deep breath and go to WPML -> Theme and plugins localization and spam the 'scan the theme for strings', then go back and repeat last step
 
If it still fails, you might want to create a class with fields as the string you're interested in and use it to spawn dummy objects. Not sure if this helps, but I did it this way, because I don't know exactly when the registration occurs...
 
In conclusion, I hope this will help someone else, despite it being a rather dirty solution. I'm going to settle with this until - hopefully - native Pagelines sections will do this by default. Alternatively, a hook solution would also be nice, but at least for iBox, none of the hooks share scope with the variables, so Hooker was useless for this…
 
Cheers!

Edited by radm, 24 February 2014 - 05:20 PM.

  • James B and nuovait like this

#6 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 25 February 2014 - 01:06 AM

Hi there, glad you got it working, thank you for posting the solution that will definitely help others in the future.



#7 erikernst

erikernst

    Newbie

  • Members
  • 1 posts
  • Framework Version:2.4.3
  • Country: Country Flag

Posted 09 March 2014 - 04:28 PM

I am having a lot of issues with compability between WPML and DMS, some sections don¨t translate, images in Revslider doesnt work on translated pages etc. All in all, DMS and WPML seem close to being a complete useless match imo. 

 

Hi there, there are issues with WPML that the core team are aware of.

 

 

I really hope to hear some news about this soon.



#8 Danny

Danny

    Is Awesome!

  • Moderators
  • 16897 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 10 March 2014 - 09:45 AM

@erikernst - I have never used the plugin. However, a lot of our users do and do not have any issues with it. As this is a premium plugin its difficult to assist you.

 

If you can provide a link to our site and also make sure that all other plugins are disabled and DMS Debug mode is active, we can take a closer look.