PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 23, 2022

[FIXED] How to use variable parameters in Yii::t method?

 January 23, 2022     internationalization, yii     No comments   

Issue

It seems Yii::t can't work with variables. I was wondering is there any solution or workaround to do something like this:

foreach ($dicts as $dict) {
    echo Yii::t($dict,$someRandomWord);
}

Solution

Tested it right now. It works fine! I promise, your locales or your $category is unknown/notset. Is your message file ok?

Check this: http://www.yiiframework.com/wiki/243/how-to-translate-and-do-the-translations-the-easy-way/#hh1

 //current language is turkey, system language is english
 $category = 'app';
 $message = 'english';

 echo Yii::t($category, $message);
 //İngilizce


Answered By - lin
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing