• Resolved szymonkurek

    (@szymonkurek)


    Hello,
    When translating typical, plain string like:
    “this is a simple string”
    everything works as expected.
    but when this string has an inner tag, like:
    “this is a <strong>simple</strong> string”
    the translation doesn’t work as wordpress separates the tagged word as a separate string
    Furthermore, it adds a ton of new lines to it, so in the HTML structure, it looks like that:
    “this is a”
    “<strong>simple</strong>”
    “string”
    Obviously, the TRP cannot understand this crap and is not able to show/link any translation to it.
    Is there any walkaround to fix this issue?
    We’ve got a lot of posts with <strong> and other tags and we need a way to translate them in some way.
    Please help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    This is currently our way of detecting formated words inside a string. In terms of automatic translation, there are cases where manual editing is required. This may not work 100% due to the limitations of machine translations and how the content is created and will need manual touch-ups from time to time.
    You can transform that piece in to a translation block (click the arrow up icon to select the entire paragraph), don’t add a translation to it, save it and it should be translated as an entire block.
    Please understand, this is split into smaller pieces by design. We don’t select just the text, we need to have the HTML as well or it won’t work otherwise.

    At the moment, our dev team is working on a way to handle the process of translating formatted words much smoothly. It will be integrated into our plugin when we have a more stable approach.

    Best Regards,

    Thread Starter szymonkurek

    (@szymonkurek)

    The thing is, I’m translating everything through API.
    If it doesn’t work, then this plugin has no use to us as we’re doing hundreds of pages.
    We made the whole workflow around this plugin and now… holy crap…

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    TranslatePress splits HTML-formatted content into multiple translation strings (text + tags) in order to preserve structure and prevent breaking the layout when translations are saved. This design choice can indeed make things tricky for fully automated API-based translation flows.

    Unfortunately, at this stage, there’s no direct workaround via the API to merge those fragments automatically. However, you can try the following approach:

    1. Translate entire blocks instead of split strings.
      When possible, set the translation block through the visual editor (or identify the block ID via the database/API) and translate it as a whole. This helps avoid the <strong> or <em> tag separation issue.
    2. Use pre-cleaned text for API translation.
      If your workflow allows it, you can strip or temporarily replace inline HTML tags before sending text for translation, then reinsert them after getting the translated result.

    We truly value that you’ve built your system around TranslatePress, and we’re taking this feedback seriously to make sure the system becomes smoother in the future.

    Thread Starter szymonkurek

    (@szymonkurek)

    This is our workflow:
    1. We create a new post
    2. Use custom API endpoint to GET the structured post (dedicated function)
    3. Fill translations for each sentence
    4. Send the translation back via custom API endpoint (another function), saving it directly into the database (into TRP table)
    This workflow works flawlessly, until there’s text with inner tag, like mentioned <strong>.

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    While we’d love to assist with every customization request, our primary focus is on supporting the core features of our plugin. As a small team, we aim to provide the best possible support for the functionality that serves all our users effectively.

    However, if you need help with custom coding, we highly recommend Codeable, as we consistently hear great feedback about their expertise.

    We truly appreciate your understanding!

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

The topic ‘Problems translating strings that contain inner tags’ is closed to new replies.