dongsi0625 2009-09-12 19:05
浏览 38
已采纳

如何使gettext始终使用翻译而不是默认语言文本

When you call the gettext php function for translating text to another language, it uses the text you have on the page to act as the KEY/ID to lookup the value to replace it with

echo gettext('hello how are you today');

that would be the text used to lookup the translation, however I would like to use something like this

echo gettext('welcome_message');

and have that translated into English and any other language I offer. So how could I make this happen? How can I make gettext function ALWAYS use a language file? So if my default language is English for the site then instead of gettext showing welcome_message to an English user it would show hello how are you today

Is it as simple as just creating an English language file in addition to the other language files?

  • 写回答

1条回答 默认 最新

  • doumen5895 2009-09-12 20:44
    关注

    You're on the right track. The string argument to gettext() is just an identifier, not a "default language". If there is no translation in the active locale, then gettext will return that identifier.

    Your solution is just what you suspect: just create an English translation file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿