Code Monkey home page Code Monkey logo

Comments (2)

nicksnyder avatar nicksnyder commented on June 2, 2024

Unfortunately delimiters can only be set per message right now.

This is an example of how to do this in code: https://sourcegraph.com/github.com/nicksnyder/go-i18n/-/blob/v2/i18n/example_test.go?L126

But you should also be able to specific this per message in the json file like this

{
    "hellomessage": {
        "other": "Hello <<.Name>>",
        "leftdelim": "<<",
        "rightdelim": ">>",
    }
}

I think the original reason I didn't add the option to set this on the bundle, or more globally, is because the current structure of the file format doesn't make it easy to add file level config (the top level is messages), and if you just put this config in code then the message files are not portable. Message files not being portable is probably not a big deal, so it seems like it could be fine to add an option to support this on the bundle.

I am curious, what is your use case for using different delimiters? Are you interested to contribute a PR?

from go-i18n.

lucijaff avatar lucijaff commented on June 2, 2024

@nicksnyder thanks for the quick response! The JSON example should work for what I need.

In my case, I would like to use different delimiters because I'm using the strings in a templating engine that also uses {{ and }} as tag delimiters, so at times, there's a clash. But since the problem is not global, setting them per message where needed will work great.

from go-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.