Support » Plugin: Loco Translate » Sources parser not supporting concatenated strings

  • Resolved lucerny

    (@lucerny)


    Hi,

    First of all, thanks for a great plugin.

    Today I have noticed Loco isn’t fully extracting concatenated strings from theme’s source files. For example this will result in only the very last piece of string (‘long line’) being extracted when syncing POT template with sources:

    _x(
      'Some very ' .
      'long line',
      'context',
      'domain'
    );

    Should this be considered a bug?

    • This topic was modified 2 years, 1 month ago by lucerny.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tim W

    (@timwhitlock)

    It’s not a bug, it’s a limitation.

    Strings requiring runtime evaluation won’t be extracted. That means no __($var) no __(COSNT) no __( call() ) and so on..

    I have no plans to make an exception for simple concatenation. It simply invites the use of dynamic strings, which is against WordPress best practice. You will find no such examples anywhere in the WordPress codebase.

    If your strings are so long they don’t fit on one line of code in your editor, I’d suggest breaking them up into sentences. This would also reduce the number of translations you’d invalidate when you change an English sentence. Don’t forget they’re also unique lookup keys.

    I see. Thanks for clarification 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sources parser not supporting concatenated strings’ is closed to new replies.