dtch60248
2014-07-16 11:48
浏览 27
已采纳

Codeigniter框架中的语言问题

I have a language file called theme.php and in this file there is the line

$LANG['sources_HAVE_AN_ACCOUNT'] = "Have an account?";  

Now in the file called votes.php i am using the code:

 if($r) //voting done
 {
 echo "". $LANG['sources_HAVE_AN_ACCOUNT']." <a href='../login' target='_blank'  #0087F7; text-decoration: none; font-weight: bold;'>".$LANG['header_LOGIN_title']."</a>";
 }
 elseif(!$r) //voting failed
 {
 $effectiveVote = getEffectiveVotes($id);
 echo $effectiveVote." ".$LANG['sources_POINTS_title'];
 }  

to allow users to perform a vote in a specific article.

The problem is that when you click on the vote button the text “Have an account?” doesn’t appears!!

Why is this happens? Where is the problem?

图片转代码服务由CSDN问答提供 功能建议

我有一个名为theme.php的语言文件,在这个文件中有一行 \ n

  $ LANG ['sources_HAVE_AN_ACCOUNT'] =“有帐户吗?”;  
   
 
 

现在在名为votes.php的文件中,我正在使用代码:

  if($ r)  //投票完成
 {
 echo“”。  $ LANG ['sources_HAVE_AN_ACCOUNT']。“&lt; a href ='.. / login'target ='_ blank'#0087F7; text-decoration:none; font-weight:bold;'&gt;”。$ LANG ['header_LOGIN_title  ']。“&lt; / a&gt;”; 
} 
 elseif(!$ r)//投票失败
 {
 $ effectiveVote = getEffectiveVotes($ id); 
 echo $ effectiveVote。“”。$  LANG ['sources_POINTS_title']; 
} 
   
 
 

允许用户在特定文章中进行投票。

问题是当你点击投票按钮时,文本“有一个帐户?”没有出现!!

为什么会发生这种情况? 问题出在哪里?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxin1884 2014-07-16 12:44
    已采纳

    Several things to check :

    • Your theme_lang.php file must be located into application/language/english/
    • Add theme to the $autoload['langage'] array located in application/config/autoload.php
    • Check in application/config/config.php that your $config['language'] is set to english

    Then, to use the translations in your votes.php controller, use this :

    $this->lang->line('sources_HAVE_AN_ACCOUNT');
    

    You can find more info in the Language Class documentation of Codeigniter

    点赞 打赏 评论

相关推荐