Git Product home page Git Product logo

Comments (5)

mikeedwards avatar mikeedwards commented on August 31, 2024 1

Hmm, yeah. Well, I just merged #84 which allows people using the module to push in g2m options that would fix the replacements or set them however they like. It won't help the command line users, but at least it's something.
At some point, I just need to bite the bullet, move one major version up, and re-write this thing in modern JS, probably even TS, and toss out the old weird stuff that changing right now will break for a ton of folks. Someday...

from po2json.

mikeedwards avatar mikeedwards commented on August 31, 2024

Hey @maximelebastard! Thanks for the bug report—this project lives and dies by the very specific issues our users find.

Not to kick you further upstream, but it looks like the original problem comes from gettext-to-messageformat. It's a great module that goes a lot further in effectively converting po files to mf than we were doing originally pre 1.0, but it does appear to be the source of your braces escaping issue.

Nevertheless, I have a PR up on this repo that addresses your issue directly by un-escaping the braces in the most brute-force way possible. Take a peek at #78 and see if that solves your problem. If it seems like it fixes things for you, great! It may be a decent stopgap until g2m resolves this, if that project feels it needs to.

from po2json.

JvJefke avatar JvJefke commented on August 31, 2024

Hey @mikeedwards,

It seems that you can manage the replacements through the options in gettext-to-messageformat parsePo function:
See: https://github.com/messageformat/gettext-to-messageformat/blob/master/index.js

The first replacement causes the above issue I think. Is there a way to expose this option or to disable the first replacement by default?

from po2json.

mikeedwards avatar mikeedwards commented on August 31, 2024

Hmm, that does look promising. My main concern would be if there are any unintended consequences in removing that escaping. Is this a problem that you're running into with your own projects? Would you mind testing a branch if I make one that fixes this by changing the g2m defaults? The big trick with making updates to po2json is that people have many different languages, uses etc. that I'm not always able to cover in the tests beforehand, so I like to check in with folks using it in the real world for updates like this.

from po2json.

JvJefke avatar JvJefke commented on August 31, 2024

@mikeedwards That is a valid concern. If implemented this way, this would mean a breaking change.

The alternative is to optionally expose that option in some form in the po2json options and let de default behaviour be like it is now.

Our frontend implementations use ngx-translate (https://github.com/ngx-translate/core).
They use variable injection with the {...} placeholder. Using po2json breaks the variable injection.

from po2json.

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.