Comments (2)
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.
@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)
- Locale Precedence not working HOT 1
- Add "README.zh-Hans.md" file to ".github" folder? HOT 1
- How to translate strings with template syntax? HOT 4
- How to generate translations for multiple packages inside same module
- How to write a library module designed to be consumed by clients requiring i18n support?
- go get -u "github.com/nicksnyder/go-i18n/v2/i18n" # cd /root/go/GOCODE/src/github.com/nicksnyder/go-i18n; git pull --ff-only HOT 2
- Please explain how the user's current language is selected at runtime
- Is there are way to properly handle translation based on gender HOT 1
- Error handling is faulty HOT 3
- How to generate translations for the toml files HOT 3
- Upgrade golang.org/x/text v0.3.8 HOT 1
- `goi18n extract` doesn't seem to work for source file that use generics HOT 3
- Cound you export this function or when translation has error get the original value HOT 7
- Hook to commonly catch errors HOT 4
- Just a review
- Easy wrapper around this library HOT 1
- List fitting problem HOT 3
- merging new translation into existing translations omits the hashes
- [Question] Is there any way for reverse lookup in bundle? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-i18n.