Giter VIP home page Giter VIP logo

Comments (9)

ArsSirek avatar ArsSirek commented on June 22, 2024 1

Hi, I wrote an example showing my usage, wasn't sure how to provide it, so I forked and added it here in examples folder #10

And there is a branch on that fork, that shows a problem I mentioned in this issue
to reproduce you can,

  • switch to that branch, npm i
  • npm run extract-intl (that will add an gb.json to locales folder with empty strings as there is no translation yet)
  • npm run start
    now when you choose gb as locale, the messages with variables remain as they are in file, despite that we have all it needs to place the variables
    Hope that helps, best of luck!

from react-intl-universal.

cwtuan avatar cwtuan commented on June 22, 2024

Could you show the detail of this case? How do you use defaultMessage method?

from react-intl-universal.

Panoplos avatar Panoplos commented on June 22, 2024

Actually, variables are ignored in the case of using intl.get('something', {foo}).d('something {foo} bar'), so this seems like a bug, as this call results in 'something {foo} bar'. Kind of meaningless to have defaults if this is the case.

from react-intl-universal.

cwtuan avatar cwtuan commented on June 22, 2024

@Panoplos
It should be intl.get('something', {foo}).d(`something ${foo} bar`)

from react-intl-universal.

Panoplos avatar Panoplos commented on June 22, 2024

The documentation doesn't mention this.

screen shot 2018-04-26 at 12 11 41

from react-intl-universal.

Panoplos avatar Panoplos commented on June 22, 2024

Or rather, it does in the API section, but why is the default variable tag spec different from the locale data?

We have a script that automatically scrapes out defaults to build the base locale, having these be different requires us to remove the $.

from react-intl-universal.

cwtuan avatar cwtuan commented on June 22, 2024

@Panoplos
The defaultMesssage is now ES6 Template literals format. And the locale file is ICU format.

I will make this intl.get('something', {foo}).d('something {foo} bar') work, too, in next release.
Thanks for the suggestion.

from react-intl-universal.

liuyiliuyi avatar liuyiliuyi commented on June 22, 2024

@cwtuan Hi, is there any progress.

from react-intl-universal.

cwtuan avatar cwtuan commented on June 22, 2024

@liuyiliuyi
After reconsideration, I'd like to remain the current behavior for this API, because this proposal may make break changes.

And you could use react-intl-universal-extract
to extract the text in source code to locale files. It will remove the $ automatically.

from react-intl-universal.

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.