简体   繁体   English

i18n Smarty变量转换为lang()

[英]i18n Smarty variable into lang()

I want to use smarty loop with variables from mysql Table on PHP 我想将Smarty循环与PHP上的mysql表中的变量一起使用

{section name=row loop=$userCoursesList}
<h1> {lang('profile.{$userCoursesList[row].course_name}')} </h1>
{/section}

And for an example the output should be: 例如,输出应为:

{lang('profile.english}')}
{lang('profile.french}')}
{lang('profile.business}')}

But probably I'm not using the right syntax, because if I write only 但是可能我没有使用正确的语法,因为如果我只写

{$userCoursesList[row].course_name}

SQL statement is working and gives me (english, french, business) SQL语句正在运行,并给我(英语,法语,商务)

And if I just write: 如果我只是写:

{lang('profile.english}')}

This works too and gives me "English Language Course" from my .php language file 这也可行,并从我的.php语言文件中为我提供了“英语课程”

I don't know what is wrong, if somebody can help me, thanks in advance 我不知道出什么问题了,如果有人可以帮助我,请先谢谢

我不确定这是否行得通,但是您可以尝试:

<h1> {lang('profile.'|cat:$userCoursesList[row].course_name)} </h1>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM