Giter Club home page Giter Club logo

Comments (2)

miracle2k avatar miracle2k commented on July 17, 2024

There might be a bug here. Part of the problem seems to be that Android behaves strangely here:

http://stackoverflow.com/questions/4414389/android-xml-percent-symbol

That is, if you want to use formatting on your string, we will need to use "%%". If you use "%%" without passing it through a formatting function, it will output two percent signs.

Of course, android2po cannot know how you will use the string on your source code.

I see a couple of options:

  1. Support formatted=false and require its use for cases such as this, so that android2po knows how to handle it.

  2. Encode all percent signs. Since the translator is supposed to keep the variables verbatim anyway, why not treat it as regular text? I'm actually not quite sure how the "c-format" declarations affect the behaviour of gettext tools, if they serve any purpose other than being for information purposes. Maybe they do.

  3. Special-case a string based on whether it contains "true" format strings. That is, if there is %1$s, assume the string will be passed through string formatting on the Android side, and should be a format string in gettext as well.

    If there is no actual placeholder, assume that the string will not be formatted, and that a percent sign therefore means the actual character, and should be escaped such that gettext doesn't think of it as a placeholder.

    This is essentially an auto-detection for the "unformatted" attribute. I'm naturally concerned about side effects.

from android2po.

bkeller-vuzix avatar bkeller-vuzix commented on July 17, 2024

I needed this too, and we use formatted="false" in our XML. A solution for this is submitted with #73

from android2po.

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.