Support » Plugin: Google Language Translator » Translating text only inside a certain element

  • Resolved Daedalon


    We have a site language setting that translates all the generic strings baesd on our own language files. We need an automatic translation to translate only certain elements, typically the post text content.

    How could we get the plugin to translate only elements that have the CSS class translatable?

    This is crucial as the pagewide translation causes many issues. For example proper nouns should never be translated. The worst example is the English to English translation of “… in Finland” to “… in Australia”.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Rob Myrick


    Hi Daedalon, this is not yet possible, but it will be coming. Most updates lately have been re-arranging things to prep for those upcoming changes, but for sure they are coming.

    Thanks for presenting this as a feature that’s needed.

    Rob Myrick

    Plugin Author Rob Myrick


    Of course, you could actually add class="notranslate" to all the elements you DO NOT want translated. This might be the only way to do this anyway, even in the future. You will need to use PHP conditionals to this on the select pages where you want this to happen, so with a little creativity, it can be done.

    Let me know if this helps.

    Thanks, Rob

    Thanks for the replies, Rob. Adding a class to each and every text element on our page except the one we want to translate seems like a potentially working approach but one that would yield side effects, including but not limited to slower page rendering times for users.

    I have understood that Google Translate API allows to translate web pages or strings. Same for Bing Translator API if I remember correctly. Your plugin would be an ideal solution for both if it only allowed to specify an element from which it would retrieve the containing text as a string to translate.

    Of course in practice that may require rearranging considerable amounts of current plugin code. To translate a string the plugin shouldn’t let Google JS change the page, but the plugin should have its own JS that would query for the translation and then change the page accordingly.

    Plugin Author Rob Myrick


    Thanks Daedalon, this is good point.

    But then we get into the issue of whether or not I pay for the Google API service, correct? That’s $20 per 1 million characters of translation which I’m responsible for from all users who use this plugin, right? That’s why I have not used that service yet.

    Maybe I don’t understand the service, I don’t know.

    And of course, the original intention of the this plugin was only to offer the free tool for users to add to their website, which I’m guessing has more limitations that using Google API directly.

    I like your idea though – and this would be a good top-notch product that I could offer.

    Let me know if you understand the Google API service differently. I would consider purchasing it, if I didn’t feel as if I”m responsible for 90K+ downloads worth of translations @ $20 / million.

    Thanks so much – I appreciate you making me think of this.


    Plugin Author Rob Myrick


    I’m closing this, since no solution is yet available in the plugin for this request to be solved.

    Sure. Sorry, hadn’t time to reply properly, but it’s a short thing to say: didn’t realize that Google would charge for the translation when not translating complete pages. In that case it seems like this could be useful feature only for those who have their own API key to use.

    Open question to anyone: is there an automatic translation service that allows translating strings without a charge? It’s enough if it’s free for low or moderate amounts of usage.

    Plugin Author Rob Myrick


    Daedalon, thanks for sending this. Yes, I think access of any sort to the Google API costs money, no matter what the capacity. I think it used to be free.

    And I’m totally open to upgrading to the API, but I don’t understand how I would take on the financial burden for each person’s website translations. As I understand it, I would be paying for all of the translations of my users, correct?

    And if my users have their own unique API key, does this mean they accept the charges for my product providing translations on their site?

    If that is the case, I would definitely buy the API access and build an even better plugin.

    Thanks again man!


    Hi Rob, a quick comment: yes, the possibility I thought of was users having their own API key and paying for the charges for using it. Not sure about the demand, just crossed my mind that for someone who is willing to pay for translations, the easiest way to set the technical parts might be if your convenient plugin offered it.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Translating text only inside a certain element’ is closed to new replies.