【问题标题】:Is it possible to have messages with multiple lines in translation files of Yesod?Yesod的翻译文件中是否可以包含多行消息?
【发布时间】:2018-01-11 05:33:51
【问题描述】:

我正在按照以下链接中的说明在 Yesod 脚手架应用程序中执行 i18n:https://github.com/yesodweb/yesod/wiki/i18n-messages-in-the-scaffoldinghttps://www.yesodweb.com/book/internationalizationhttp://haddock.stackage.org/nightly-2016-04-19/shakespeare-2.0.8.1/Text-Shakespeare-I18N.html

它看起来像一个en.msg 文件,例如:

Hello: Hello World!
MultilineText: 
  line 1.
  line 2.
  etc...
SingleLine: A single line message.

不支持,因为 MultilineText 定义。这是真的还是有办法/语法可以做到这一点?

【问题讨论】:

标签: haskell internationalization yesod


【解决方案1】:

从来源来看,不,不可能:

loadLangFile :: FilePath -> IO [Def]
loadLangFile file = do
    bs <- S.readFile file
    let s = unpack $ decodeUtf8 bs
    defs <- fmap catMaybes $ mapM (parseDef . T.unpack . T.strip . T.pack) $ lines s
    return defs

parseDef 函数对lines 调用的结果进行操作,通过换行符分割文件内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-12
    • 2016-05-24
    • 2019-02-14
    • 1970-01-01
    • 2021-08-17
    • 2010-11-29
    • 1970-01-01
    • 2011-12-24
    相关资源
    最近更新 更多