• Resolved Christoph

    (@camthor)


    In a plugin I would like to display several paragraphs of HTML-formatted text, with large passages without any PHP or variables inside. So far I’ve been using the usual __() or _e(), wrapped by the HTML tags and concatenated. The problem I see is that:

    1. The code becomes very bloated and difficult to read.
    2. Translators only see one sentence at a time and don’t have the context. So, resulting sentences might not fit together.
    3. Depending on the progress of translators, the result might be a mixture of original and target languages.
    4. The text is a bit difficult to browse and edit.

    Now I was thinking about simply including the entire text in one go from a separate text file that contains nothing but that text. Is it still possible to make this text available for localization? Do I have to wrap the text in the external file in _() and execute it as PHP script? Or is there any way how to tell WordPress that this is translatable content and what is the text domain?

    Thanks for sharing your experiences!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Why so much text? Extended instructions or help information? The translation functions are intended for user interface phrases, not extended prose. You can keep the text in a separate file for organizational purposes, but for it to be picked up for translation it still needs to be a PHP file that’s part of your plugin’s code base.

    It sounds to me like this text has moved from the “code” realm into the “content” realm, in which case it should be handled like other multi-lingual content. Of course the issue is the site using your plugin may not be multi-lingual and there’s no consistent way of managing multi-lingual content like there is for UI elements. What many plugin devs do is link users to their own website for extended instructions or help content. Your site can be multi-lingual or you could place that Google translation widget thingy on the instruction/help pages so users can view the content in any language they choose, though not always that well translated.

    This has the added benefit of keeping users in contact with you. You can then also present topical information like upgrades, other plugins, support tickets, current issues, etc., much of which would not be allowed in plugins that reside in the wp.org repository.

    Thread Starter Christoph

    (@camthor)

    The text is a list of shortcode parameters. I always found it useful to have them directly in the admin screen so that I needn’t load other websites.

    Yes, most of the instructions and examples are on external websites. I will definitely keep them there.

    Moderator bcworkz

    (@bcworkz)

    I see. In that case I see no problem with each parameter phrase being a separate, translatable item. The description should be as brief as possible as a quick reference item. If an extended explanation is also desired, perhaps that part can be linked to an external help page.

    If your shortcodes are that elaborate, you might consider building some sort of contextual pick and choose UI to assist in the construction of proper shortcodes. These help reduce syntax errors and alleviate the user from needing to remember or look up a bunch of different parameters. A lot more work for you and totally optional of course, but something to at least think about.

    Thread Starter Christoph

    (@camthor)

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Best practice to add long text for localization?’ is closed to new replies.