admin管理员组文章数量:1406715
I want to translate my functions.php with custom code in it.
There I have a Class "Glbl_Helper" with a public static array that contains strings like "translate_me".
Now I want to translate the strings using WPML. But If I do it like in the Text-Snipped with "translate_me" and "translate_me_2" I get the error:
Fatal error: Constant expression contains invalid operations in /www/.../functions.php on line 502
Line 502 is in the functions.php in my code and the line 502 is: public static $step_questions = array(
if ( ! class_exists( 'Glbl_Helper' ) ) {
class Glbl_Helper
{
// Added keys for question array below
const QUESTION_KEY = "question";
const ANSWER_KEY = "answer";
const INVALID_ANSWER_KEY = "invalid_answer";
const ANSWER_FILTER_KEY = "answer-type-filter";
const ANSWER_FILTER_FLAGS_KEY = "answer-type-filter-flags";
// Added static array to define questions for each child step, where a question needs to be answered
public static $step_questions = array( //This is the code line 502 from the error
self::STEP_BROKER_SIGN => array(
self::QUESTION_KEY => __("translate me", "text_domain"),
self::ANSWER_KEY => esc_html__("translate_me_2", "text_domain"),
self::INVALID_ANSWER_KEY => "translate_me_3",
self::ANSWER_FILTER_KEY => FILTER_SANITIZE_STRING,
self::ANSWER_FILTER_FLAGS_KEY => FILTER_REQUIRE_SCALAR
),
);
...
}
}
Can anyone tell me how I have to change my code so I can use WPML String translation to translate the Questions and Answers in the Array?
本文标签: translationHow to Translate a string of an array inside a class
版权声明:本文标题:translation - How to Translate a string of an array inside a class? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744934660a2633107.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论