Coder Social home page Coder Social logo

react-intl-native's Introduction

react-intl-native

Build Status Dependency Status devDependency Status codecov.io

react-intl convinience components for React Native

While react-intl allows us to use formatMessage or passing in a function, this becomes tiresome if you have to do this for each. This module does the latter and wraps it all in a Text component allowing you to pass in style to provide custom styling.

Installation

$ npm install react-intl-native

Usage

Wrap your main component inside react-intls IntlProvider like you would in your web application:

import IntlProvider from 'react-intl';
<IntlProvider locale="en">
  <MainView />
</IntlProvider>

FormattedDate

<FormattedDate
  weekday="long"
  value={Date.now()}
  style={{ fontWeight: 'bold' }} />

More information on date formatting options: https://github.com/yahoo/react-intl/wiki/Components#date-formatting-components

FormattedHTMLMessage

<FormattedHTMLMessage
  defaultMessage="Hello there"
  style={{ fontWeight: 'bold' }} />

FormattedMessage

<FormattedMessage
  defaultMessage="Hello there"
  style={{ fontWeight: 'bold' }} />

FormattedNumber

This is the only component that differs slightly from the original component. For the formatting style you need to use formatStyle instead of style. style is being reserved for the component styling.

<FormattedNumber
  formatStyle="currency"
  value={1000}
  style={{ fontWeight: 'bold' }} />

More information on number formatting options: https://github.com/yahoo/react-intl/wiki/Components#formattednumber

FormattedPlural

<FormattedPlural
  value={10}
  one="message"
  other="messages"
  style={{ fontWeight: 'bold' }} />

More information on plural formatting options: https://github.com/yahoo/react-intl/wiki/Components#formattedplural

FormattedRelative

<FormattedRelative
  value={Date.now()}
  style={{ fontWeight: 'bold' }} />

More information on date formatting options: https://github.com/yahoo/react-intl/wiki/Components#date-formatting-components

FormattedTime

<FormattedTime
  value={Date.now()}
  hour="numeric"
  style={{ fontWeight: 'bold' }} />

More information on date formatting options: https://github.com/yahoo/react-intl/wiki/Components#date-formatting-components

For more information, take a look the react-intl documentation: https://github.com/yahoo/react-intl/wiki/Components

License

MIT

react-intl-native's People

Contributors

dusave avatar frostney avatar kirno avatar misogl avatar wenterline-godaddy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-intl-native's Issues

Invariant Violation: Expected a component class, got [object Object].

Hi,

I followed all steps and added below code in

<FormattedDate
weekday="long"
value={Date.now()}
style={{ fontWeight: 'bold' }} />

But I get Invariant Violation: Expected a component class, got [object Object]. error

Can you please share an example how to use this package

"babelHelpers typeof" issue when adding this package in my RN app

Hi,

From what I can see about this error, it's because the package is providing too much (unnecessary) transformations. I see that es2015 is used to transform this package.

Why is this transformed? I am new to RN (but not React & babel) and it seems that most package on npm are not transformed when published. Am I right by thinking we should remove some transformation here? (note that I am using RN 0.34)

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.