• Resolved fff654

    (@fff654)


    Hi,

    I have seen your code to get the URL of a translated page (and works fine, thanks). But what are the PHP codes to:

    • get the translation of any string from the defined source language ? anything like mystring = translate_function(“this string”, into_that_language); ? (ideally, it would either pull it from already translated strings, or dynamically translate it if credits are available -if only doing partially, or other way, please still tell-)
    • get the translation of the full page content ? (either already translated, or in the current state that it would be shown). I am sure the current translated state must be stored somewhere, in a field or elsewhere to be displayed fast on the frontend. My idea for this is to try to get around the TranslatePress limitation that the translated content is not searchable in the WP search feature -very annoying-, so I would give that content somehow to the search plugin I am using to force its indexing & appearing in search results. So what is your equivalent to get_the_content() function ? (with shortcodes rendered and translated ideally) ?

    Thanks

    • This topic was modified 4 months, 2 weeks ago by fff654.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Anca

    (@ancavictoria)

    Hello,

    get the translation of any string from the defined source language ? anything like mystring = translate_function(“this string”, into_that_language); ? (ideally, it would either pull it from already translated strings, or dynamically translate it if credits are available -if only doing partially, or other way, please still tell-

    You can use the trp_translate function according to our documentation: https://translatepress.com/docs/translation-function/

    get the translation of the full page content ? (either already translated, or in the current state that it would be shown). I am sure the current translated state must be stored somewhere, in a field or elsewhere to be displayed fast on the frontend. My idea for this is to try to get around the TranslatePress limitation that the translated content is not searchable in the WP search feature -very annoying-, so I would give that content somehow to the search plugin I am using to force its indexing & appearing in search results. So what is your equivalent to get_the_content() function ? (with shortcodes rendered and translated ideally) ?

    Any plugin that relies on an index may not function correctly with TranslatePress, as it works with the default WordPress search, while custom queries or AJAX-based searches may continue to search in the original language.
    If you’re using the default WordPress search, you need to first view the page in the additional language for it to appear in the search results.

    We have documentation about how you can implement a custom search solution: https://translatepress.com/docs/developers/implementing-a-custom-search-solution/.

    Kind regards,

    Anca

    Thread Starter fff654

    (@fff654)

    Hi Anca,

    Thanks for the heads up on the first question. Obviously I missed that chapter which is well explained.

    For my second question, your post is proposing one route to solve the “dynamic translation” consequence, ie some direct hooks during the search itself. I have other ways. Can you please tell me how to get the full translated post content or where is it stored ?

    Plugin Support Anca

    (@ancavictoria)

    Hello,

    You’re very welcome! 

    TranslatePress saves translations directionally from the default language into the additional language(s) in your local database, in the *_trp_ tables.

    The content is translated and stored string by string – it is not possible to translate or save it per page or post.

    Kind regards,

    Anca

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.