I have a class (MetricUnits
) that looks like this:
class MetricUnit {
const SIZE = [
"value" => 0,
"text" => Yii::t("app", "Size")
];
}
Yii::t
is a i18n function.
As you'd be probably thinking by now, this is invalid as PHP doesn't allow expressions in const.
How can I avoid that limitation so I could get the text of that cons?
Btw, Yii::t
doesn't take any non-string values, not even const values, so I can't do something like:
class MetricUnit {
const SIZE = [
"value" => 0,
"text" => "Size"
];
}
Yii::t("app", MetricUnit::SIZE["text"]);