Yii2如何获取翻译消息的长度

Yii2 how to get the length of translated message

在我的项目中,我试图在我的一个模块中提供动态调整大小。我想在 yii2 国际化中弄清楚如何获得翻译文本的字符串长度。

例如:

 <?php 
       //I am getting the name from the database. Assume name to be "Hello"
       $name = $gettingNameFrom->db;

       //Now $name is equal to string "Hello"

       //The below function will dump the output to be int(5) as the length of hello is 5
       var_dump(strlen($name));

       //Now I want to apply translation to the above name in the db.
       // I have all my translation configured and working fine.

       echo Yii::t('app','{0}',[$name]);
       //I have configured fo french language.
       // the above output for "Hello" in french would be "Bonjour".



    ?>

现在如何获得翻译文本的长度?我无法在网上找到有关此主题的任何帮助。任何帮助表示赞赏。

谢谢!!

$translated = Yii::t('app', $name);
var_dump(strlen($translated));