Pergunta

The built-in i18n message files for Yesod are very nice but I've noticed two problems:

  1. It doesn't seem to allow comments. These can be very helpful to give translators (or remind myself of) the context for a message. Is there a comment syntax that I missed?
  2. The < and > characters are HTML-escaped. This prevents adding simple bits of HTML such as <em> to a message. Other than coding messages up in .hs files is there a workaround to this?

Thanks for any suggestions!

Foi útil?

Solução

  1. Comments are made by making lines starting with #.
  2. It might not be a good idea to force translators to deal with HTML tags if they aren't familiar with them. Also, what if you want to change some implementation detail later, like deciding you want to replace <span class="foo">foo</span> with <em>foo</em>?

    Instead, I would suggest using some Markdown-like syntax with Something that needs to be *emphasized*.. You can then post-process the strings with the various Markdown libraries on Hackage.

    This is easy to do automatically if you avoid using the mkMessage TemplateHaskell function for generating your messages and instead make your own RenderMessage class implementation that uses a Markdown syntax processor. I don't see a way of doing it while keeping the mkMessage invocation, but I know that @michael-snoyman, the creator of Yesod, might have hidden a hook in the API somewhere that allows this to happen, and he usually reads these questions on SO.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top