Comments (4)
I'd say, let's figure out what gettext
does with an empty string and try to replicate. BUT, not sure on changing current behavior due to backwards compatibility, in case somebody is using Get("")
to obtain the headers.
from gotext.
well, looks like that is indeed expected behavior from gnu gettext: https://www.gnu.org/software/gettext/manual/gettext.html#MO-Files:~:text=as%20the%20empty%20string%20in%20a%20PO%20file%20GNU%20gettext%20is%20usually%20translated%20into%20some%20system%20information%20attached%20to%20that%20particular%20MO%20file%2C%20and%20the%20empty%20string%20necessarily%20becomes%20the%20first%20in%20both%20the%20original%20and%20translated%20tables%2C%20making%20the%20system%20information%20very%20easy%20to%20find.
it's quite inconvenient tho, but I guess most of times, the expected usage here is always inline the message you want to translate instead of passing it as a variable.
from gotext.
I understand this lib is trying to align with gettext, just wondering if it's a reasonable ask to provide a global config to disable the "" -> meta behavior ? we can still have it false by default so its backward compatible
from gotext.
I'll reject this one as I prefer to stick to gettext compatibility rather than general usage. There may be many edge cases like yours for implementations of this package, we can't always cover every case, but provide tools for them to adapt.
You should be able to wrap Get calls, or have general filters in place to safely use empty vars with this package.
You can also remove the headers from your (deployed) translation files, so Get("")
returns ""
, as it seems you don't use these headers in your code at all.
from gotext.
Related Issues (20)
- plurals subpackage appears to plagiarise github.com/ojii/gettext.go/pluralforms HOT 3
- Please add cli/xgotext to v1.4.1 HOT 3
- Project status and feature request to use embed po files HOT 7
- xgotext performance
- v1.5.0 is a breaking change HOT 3
- Get and similar functions don't always process formatting sequences HOT 1
- Keep order in po files HOT 4
- xgotext emits backtick-delimited strings into .pot files
- Exported strings can break PO file format
- Missing support for fallback translations HOT 3
- Add support for json format HOT 1
- Locale should expand the string to include country code if necessary HOT 1
- expose lang from Locale HOT 2
- can we have pseudo locale support ? HOT 5
- documentation on usage with templates? HOT 3
- Multi-line and backquotes strings support incorrect compared to gettext spec
- Plurals export into po file HOT 2
- Properly tag the latest release HOT 1
- Bug in IsTranslatedN() 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 gotext.