Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Chouby

    (@chouby)

    More information would be needed to help you. Where does this code come from? A plugin? A theme? Is it freely available?

    Thread Starter e-colori – Tobias

    (@e-colori)

    Sorry you are right.
    It is a new plugin not published yet, programmed by myself.

    This error array is filled in a function and than

    $err_mess = '';
    foreach( $error as $err ) {
    	$err_mess .= $err . '<br />';
    }
    $this->message .= '<p class="wpsmnt_error">'.$err_mess.'</p>';

    And than echoed in a second function on the frontend?
    echo $this->message;

    What I do not understand is, if I deactivate polylang it is translated?

    Plugin Author Chouby

    (@chouby)

    What I do not understand is, if I deactivate polylang it is translated

    That’s strange indeed.

    How do you load your texdomain? Did you make sure that you load it in a function attached to a hook and not as soon as th plugin is loaded?

    Thread Starter e-colori – Tobias

    (@e-colori)

    This sounds like a possibility…
    My textdomain is loaded in the

    private function __construct() {
    add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ), 1, 1);

    and

    public function load_plugin_textdomain() {
    
    load_plugin_textdomain( 'wpsmnt_', false, dirname( plugin_basename( __FILE__ ) ).'/lang/' );
    }

    You suggest it should be in a hook?

    Plugin Author Chouby

    (@chouby)

    It’s correct to put it in the ‘plugins_loaded’ hook. Could it be the that the domain is not the same? I read ‘wpsmnt_’ here and ‘_wpsmnt’ in your error text. If that’s not the issue, maybe you can try to decrease the priority from 1 to a bigger value.

    Thread Starter e-colori – Tobias

    (@e-colori)

    Thanks again, but it did not help
    It was a typing error (here in the forum) the domain is both: ‘wpsmnt_’
    I checked every priority from 1-10 no difference?

    I just checked if
    _e( 'Price', 'wpsmnt_' );
    would be translated at this point in the function.
    Same issue if I deactive polylang, it works.

    It is a mystery for me? Any more ideas?

    Plugin Author Chouby

    (@chouby)

    Sorry some times I am so slow…

    Are you setting the language from content? If yes, the language is defined quite late in a function hooked to ‘wp’ action (with priority 5). So if you store strings in a variable before this action has been fired, they won’t be translated.

    If the language is set from the url, then it is defined as soon as possible in ‘plugins_loaded’ with priority 1.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error text in an array is not translated, if polylang is activated’ is closed to new replies.