Code Monkey home page Code Monkey logo

Comments (4)

whyleee avatar whyleee commented on September 26, 2024

Yes, it doesn't work with HTML attributes too. I think it is because of gettext parsing - it just ignores regular strings and all content in them.

from i18n.

asapostolov avatar asapostolov commented on September 26, 2024

Hey. How do you work with the issue of @_("translate") in html Attributes not extracting into the .pot and .po files?

from i18n.

danielcrenna avatar danielcrenna commented on September 26, 2024

@xianjin Your referenced fix is applied
@asapostolov Can you fork a unit test that fails this? I know this is a big ask.

from i18n.

asapostolov avatar asapostolov commented on September 26, 2024

Actually I've found the problem. It's like this - if you got:

<input id="id" value="@_("Hello!")" />

gettext won't extract it in the .po and .pot files (I think) because there isn't an HTML parser and if gettext finds text _() inside C# code comments or the insides of string - it ignores it.

I found a workaround here. You just have to write the HTML like that(@_ on a new line):

<input id="id" value="
@_("Hello!")" />

However this isn't pretty if you have to do it everywhere. A more beautiful solution that I decided to work with is use custom @html helpers like that:

@Html.Input(new { id="id", value=__("Hello") })

from i18n.

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.