Results 1 to 3 of 3

Thread: Freemarker macro for i18n of links

  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Default Freemarker macro for i18n of links

    Hi there! I'm Adam. I work on Mifos. Mifos uses Spring MVC and Freemarker.

    Anyone have a macro for helping translation of messages with links?

    A set of messages like this:

    Code:
    welcome.begin=Hello, please
    welcome.linktext=click here
    welcome.end=to login.
    is much more of a pain to translate than this:

    Code:
    welcome.text=Hello, please click here to login.
    The former is called a "lego message" or a "patchwork message" by a translator. Stand-alone phrases are most amenable to translation. Since context is lost in a patchwork message, this may lead to a poor translation.

    But, as you might have guessed, the first version is more convenient for a developer when they need to wrap, say, an html anchor element around the "click here" text, like so:

    Code:
    Hello, please <a href="http://example.com/login">click here</a> to login.
    Here's a real patchwork message in Mifos (screenshot of same). We got an idea from Siebrand, one of the kind folks at Translatewiki.net to use MarkdownJ, and an example Freemarker macro using a custom link markup by Van (a Mifos developer).

    Does anyone have another way they allow messages with links to be translated as phrases? Do you use MarkdownJ, some other off-the-shelf syntax, or something custom?

    Thanks!
    -Adam

  2. #2
    Join Date
    Oct 2010
    Posts
    4

    Default SOLVED with user-defined Freemarker Markdown directive

    I played around with this a bit and I think a user-defined directive is a clean way to avoid patchwork messages.

    Example snippet of a Java properties-style resource bundle:
    Code:
    welcome.text=Hello, please [click here](%s) to login.
    Example Freemarker code to use this message:
    Code:
    [#assign mlink="org.example.ftl.MarkdownLinker"?new()]
    [@mlink dest="http://example.com/login"][@msg "welcome.text"/][/@mlink]
    Here's code for a working example (including the MarkdownLinker class referenced above).
    Last edited by meonkeys; Oct 25th, 2010 at 12:51 AM. Reason: "finally" wasn't necessary in last paragraph lead-in.

  3. #3
    Join Date
    Nov 2010
    Posts
    10

    Default

    Hello,

    I'm looking to use i18n with FreeMarker, I have a lot of files i18n_en, i18n_fr,i18n_it, ...

    My question : how do I get in my .ftl file for desplaying the good text corresponding to the local?

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •