Forum Archive - Combining manually translated French pages with GTranslate

Combining manually translated French pages with GTranslate
Oct 16, 2018 2:24 pm by oxygensmith
Hi folks, GTranslate chat isn't working for me, so I'm coming to you. The upshot of this post is that: I'm a Wordpress coder comfortable with editing PHP, Javascript, Wordpress template code. I'm wondering if it's possible to create our own GTranslate buttons on templates, instead of just activating the floating language switcher, or menu language switcher, via the plugin control panel. The reason is, we are in the situation of soon launching a bilingual site that has some pages translated to French manually. But not all pages are translated. So I am looking for: - code snippets - documentation - hooks to use in GTranslate to make what I want happen - experiences with trying to make this happen. I think I have a pretty good strategy for using GTranslate in a situation where your site has some manually translated pages, but where you need the rest of the pages (and the surrounding menu and sitewide elements, etc.) translated when someone clicks "FR." I am not using WPML to handle the translated articles, but I am using Advanced Custom Fields to create two fields for all posts and pages: 1) the language the article is in (EN or FR), and 2) its link to the other translation. So what I need to do is create an "FR" button that goes through this logic (in PHP, using Wordpress functions): - Is this a page or post that is linked to a manually translated version with a URL supplied? --- If yes, 1) go to the post or page where the manual translation exists, and then 2) translate it (via GTranslate). Fire all the cookies so that the visitor is now cruising the site in French. --- If no, just GTranslate to French normally. The reason this is ideal is because, on manually translated blog posts where it's indicated the language is French, we put a "notranslate" div around the whole article and title. When GTranslate translates a manually translated French page, the manual translation remains, while GTranslate helpfully auto-translates everything else (sidebars, menu etc). So for example, here is a site soon to be launched (please forgive the somewhat rough draft looking website): If on this page in English: ... d-climate/" rel="nofollow" target="_blank Has this translation: ... le-climat/" rel="nofollow" target="_blank Then what we *want* to do, when people are on the English page and click FR: ... d-climate/" rel="nofollow" target="_blank ... they should get here: ... le-climat/" rel="nofollow" target="_blank It would do this logic in reverse when going from ... le-climat/" rel="nofollow" target="_blank back to ... d-climate/" rel="nofollow" target="_blank What I've already tried, and why I think I have to make my own buttons: My planned, easy way to deal with this, where I wouldn't have to touch code at all, was simply to install the [url href=""]Redirection[/url] plugin. Part of the process of putting up an English and manually translated French article would then be setting up a redirect. Simple. So, in the example above, we would just set up a redirect from: ... le-climat/" rel="nofollow" target="_blank ... le-climat/" rel="nofollow" target="_blank However, this doesn't work - Redirection chokes and we get a "too many redirects" error. This is because GTranslate sets up its own redirection in the htaccess file. So, without Redirection, I think I have to set up my own EN/FR buttons that do some logic before letting GTranslate do its thing (basically, possibly supply a different URL to translate to GTranslate before GTranslate fires), but I don't yet know the best way to begin. Any and all advice or support, tips, clues, snippets, documetation, etc. are super appreciated. Would love to hear about your experiences combining autotranslation with manual translation. It's been a headache for us but GTranslate gets us *so close* to what we want! (at a very reasonable / affordable budget)
Re: Combining manually translated French pages with GTransla
Oct 16, 2018 6:39 pm by Yana
Hi, You can check our documentation here . I will ask our developer to check this .
Re: Combining manually translated French pages with GTransla
Oct 18, 2018 1:43 pm by oxygensmith
Thanks Yana. All right, this answer is kind of helpful but not totally: ... d-language" rel="nofollow" target="_blank I might be able to do something with this, but I'd like to find a hook/filter/action, if it exists, in which I can interrupt and swap in a different URL when I click the "FR" button (so I can say, "GTranslate, go to the /fr/ version of another page of my choosing (the manually translated French one) rather than the /fr/ one you associate with this English page." This would be a perfect way of handling "sites with some manual translation but not full manual translation" I think. I will keep trying but if you can explain to the developers what I'm trying to do, and get an answer, that would be great. Thanks again.
Re: Combining manually translated French pages with GTransla
Oct 22, 2018 9:05 pm by Edvard
Hi, This can be helpful: <a href="test.html" data-gt-href-fr="french.html" data-gt-href-es="spanish.html">...</a> This tells us to use french.html link instead of test.html on French version, spanish.html on Spanish version. Thanks!


Gtranslate MultisiteFeb 12, 2019 7:27 amReplies: 1Post by: infact_dat
Gtranslate: Error with numberFeb 20, 2019 1:20 amReplies: 1Post by: infact_dat
GTranslate 3.7.4, Joomla 3.9.3 - doGTranslate is not definedFeb 22, 2019 12:34 pmReplies: 1Post by: oase
Add-on gtranslate no longer worksFeb 2, 2019 6:01 amReplies: 1Post by: DarylDixon
Add links to all translated posts on every Wordpress postJan 14, 2019 8:51 pmReplies: 5Post by: ptsniper

Try GTranslate with a free 15 day trial