【问题标题】:How to use smarty to translate a website?如何使用 smarty 翻译网站?
【发布时间】:2014-11-18 22:56:32
【问题描述】:

我想用SMARTY做一个多语言网站。

我读了这篇文章: http://www.freesoftwaremagazine.com/articles/creating_multilingual_website_smarty

但是它不适用于 smarty3,我不知道这些配置是如何工作的:我是 smarty 的新手。

例如:我的网站内容现在

你好,你好吗

我可以在我的变量中使用空格吗,我不必像这样重写它:

{$hello_world_how_are_you}

但我宁愿保留类似的东西

{你好,你好吗}

/#hello world,你好吗#/

为了避免我必须翻译的每个短语都重写 slug

【问题讨论】:

    标签: smarty smarty3


    【解决方案1】:

    你可以使用数组语法

    例如

    {$lang['hello world, how are you']}
    

    这还有一个好处是你不会污染你的变量范围。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-28
      • 2013-04-07
      相关资源
      最近更新 更多