如何访问Yii2的翻译数组?

问题描述 投票:0回答:1

我想知道是否有一种方法可以在运行时访问翻译(i18n)数组。我需要访问它,以便翻转数组,并将一些东西翻译回源语言。(需要在DB上执行基于外语用户输入的SQL查询)。

非常感谢,Andras

yii2 internationalization
1个回答
0
投票

这是我的最终解决方案,虽然看起来并不漂亮。

$arr = include(Yii::getalias(Yii::$app->i18n->translations['app']['basePath'] . "/" . Yii::$app->language . "/app.php"));
© www.soinside.com 2019 - 2024. All rights reserved.