Giter VIP home page Giter VIP logo

Comments (4)

leonelquinteros avatar leonelquinteros commented on May 18, 2024

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.

taozhou-glean avatar taozhou-glean commented on May 18, 2024

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.

taozhou-glean avatar taozhou-glean commented on May 18, 2024

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.

leonelquinteros avatar leonelquinteros commented on May 18, 2024

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)

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.