Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format markdown files #1308

Merged
merged 1 commit into from Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions CONTRIBUTING.md
@@ -1,17 +1,16 @@
Contributing
============
# Contributing

Pull requests are very welcome, but should be within the scope of the project, and follow the repository's code conventions. Before submitting a pull request, it's always good to file an issue, so we can discuss the details of the PR.

## Reporting a Bug

1. Ensure you've replicated the issue against master. There is a chance the issue may have already been fixed.
1. Ensure you've replicated the issue against master. There is a chance the issue may have already been fixed.

2. Search for any similar issues (both opened and closed). There is a chance someone may have reported it already.
2. Search for any similar issues (both opened and closed). There is a chance someone may have reported it already.

3. Provide a demo of the bug isolated in a jsfiddle/jsbin. Sometimes this is not a possibility, in which case provide a detailed description along with any code snippets that would help in triaging the issue. If we cannot reproduce it, we will close it.
3. Provide a demo of the bug isolated in a jsfiddle/jsbin. Sometimes this is not a possibility, in which case provide a detailed description along with any code snippets that would help in triaging the issue. If we cannot reproduce it, we will close it.

4. The best way to demonstrate a bug is to build a failing test. This is not required, however, it will generally speed up the development process.
4. The best way to demonstrate a bug is to build a failing test. This is not required, however, it will generally speed up the development process.

## Submitting a pull request

Expand All @@ -27,7 +26,7 @@ Pull requests are very welcome, but should be within the scope of the project, a

5. Follow syntax guidelines detailed below.

6. Push the changes to your fork and submit a pull request. If this resolves any issues, please mark in the body `resolve #ID` within the body of your pull request. This allows for github to automatically close the related issue once the pull request is merged.
6. Push the changes to your fork and submit a pull request. If this resolves any issues, please mark in the body `resolve #ID` within the body of your pull request. This allows for github to automatically close the related issue once the pull request is merged.

7. Last step, [submit the pull request][pr]!

Expand Down
90 changes: 41 additions & 49 deletions README.md
@@ -1,15 +1,12 @@
React Intl
==========
# React Intl

Internationalize [React][] apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.

[![npm Version][npm-badge]][npm]
[![Build Status][travis-badge]][travis]
[![Dependency Status][david-badge]][david]


Overview
--------
## Overview

**React Intl is part of [FormatJS][].** It provides bindings to React via its components and API.

Expand All @@ -18,7 +15,7 @@ You can sign-up using this [invitation link](https://join.slack.com/t/formatjs/s

### [Documentation][]

React Intl's docs are in this GitHub [`/docs`][Documentation] folder, [__Get Started__][Getting Started]. There are also several [runnable example apps][Examples] which you can reference to learn how all the pieces fit together.
React Intl's docs are in this GitHub [`/docs`][documentation] folder, [**Get Started**][getting started]. There are also several [runnable example apps][examples] which you can reference to learn how all the pieces fit together.

_(If you're looking for React Intl v1, you can find it [here][v1-docs].)_

Expand All @@ -34,81 +31,76 @@ _(If you're looking for React Intl v1, you can find it [here][v1-docs].)_

### Example

There are several [runnable examples][Examples] in this Git repo, but here's a Hello World one:
There are several [runnable examples][examples] in this Git repo, but here's a Hello World one:

```js
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {IntlProvider, FormattedMessage} from 'react-intl';

class App extends Component {
constructor(props) {
super(props);
this.state = {
name : 'Eric',
unreadCount: 1000,
};
}

render() {
const {name, unreadCount} = this.state;

return (
<p>
<FormattedMessage
id="welcome"
defaultMessage={`Hello {name}, you have {unreadCount, number} {unreadCount, plural,
constructor(props) {
super(props);
this.state = {
name: 'Eric',
unreadCount: 1000,
};
}

render() {
const {name, unreadCount} = this.state;

return (
<p>
<FormattedMessage
id="welcome"
defaultMessage={`Hello {name}, you have {unreadCount, number} {unreadCount, plural,
one {message}
other {messages}
}`}
values={{name: <b>{name}</b>, unreadCount}}
/>
</p>
);
}
values={{name: <b>{name}</b>, unreadCount}}
/>
</p>
);
}
}

ReactDOM.render(
<IntlProvider locale="en">
<App />
</IntlProvider>,
document.getElementById('container')
<IntlProvider locale="en">
<App />
</IntlProvider>,
document.getElementById('container')
);

```

This example would render: "Hello **Eric**, you have 1,000 messages." into the container element on the page.

**Pluralization rules:** In some languages you have more than `one` and `other`. For example in `ru` there are the following plural rules: `one`, `few`, `many` and `other`.
Check out the official [Unicode CLDR documentation](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html).

Contribute
---------
## Contribute

Let's make React Intl and FormatJS better! If you're interested in helping, all contributions are welcome and appreciated. React Intl is just one of many packages that make up the [FormatJS suite of packages][FormatJS GitHub], and you can contribute to any/all of them, including the [Format JS website][FormatJS] itself.
Let's make React Intl and FormatJS better! If you're interested in helping, all contributions are welcome and appreciated. React Intl is just one of many packages that make up the [FormatJS suite of packages][formatjs github], and you can contribute to any/all of them, including the [Format JS website][formatjs] itself.

Check out the [Contributing document][CONTRIBUTING] for the details. Thanks!
Check out the [Contributing document][contributing] for the details. Thanks!


License
-------
## License

This software is free to use under the Yahoo Inc. BSD license.
See the [LICENSE file][] for license text and copyright information.


[npm]: https://www.npmjs.org/package/react-intl
[npm-badge]: https://img.shields.io/npm/v/react-intl.svg?style=flat-square
[david]: https://david-dm.org/formatjs/react-intl
[david-badge]: https://img.shields.io/david/formatjs/react-intl.svg?style=flat-square
[travis]: https://travis-ci.org/formatjs/react-intl
[travis-badge]: https://img.shields.io/travis/formatjs/react-intl/master.svg?style=flat-square
[React]: http://facebook.github.io/react/
[FormatJS]: http://formatjs.io/
[FormatJS GitHub]: http://formatjs.io/github/
[Documentation]: https://github.com/formatjs/react-intl/blob/master/docs/README.md
[Getting Started]: https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md
[Examples]: https://github.com/formatjs/react-intl/tree/master/examples
[react]: http://facebook.github.io/react/
[formatjs]: http://formatjs.io/
[formatjs github]: http://formatjs.io/github/
[documentation]: https://github.com/formatjs/react-intl/blob/master/docs/README.md
[getting started]: https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md
[examples]: https://github.com/formatjs/react-intl/tree/master/examples
[v1-docs]: http://formatjs.io/react/v1/
[CONTRIBUTING]: https://github.com/formatjs/react-intl/blob/master/CONTRIBUTING.md
[LICENSE file]: https://github.com/formatjs/react-intl/blob/master/LICENSE.md
[contributing]: https://github.com/formatjs/react-intl/blob/master/CONTRIBUTING.md
[license file]: https://github.com/formatjs/react-intl/blob/master/LICENSE.md
63 changes: 33 additions & 30 deletions docs/API.md
@@ -1,6 +1,6 @@
# API

There are a few API layers that React Intl provides and is built on. When using React Intl you'll be interacting with its API (documented here) and its React [components][Components].
There are a few API layers that React Intl provides and is built on. When using React Intl you'll be interacting with its API (documented here) and its React [components][components].

1. [ECMAScript Internationalization API](#ecmascript-internationalization-api)
2. [FormatJS Internationalization Formatters](#formatjs-internationalization-formatters)
Expand Down Expand Up @@ -80,11 +80,11 @@ This function is exported by the `react-intl` package and is simply a _hook_ for
import {defineMessages} from 'react-intl';

const messages = defineMessages({
greeting: {
id: 'app.home.greeting',
description: 'Message to greet the user.',
defaultMessage: 'Hello, {name}!',
},
greeting: {
id: 'app.home.greeting',
description: 'Message to greet the user.',
defaultMessage: 'Hello, {name}!',
},
});
```

Expand Down Expand Up @@ -113,14 +113,14 @@ import React, {PropTypes} from 'react';
import {injectIntl, intlShape, FormattedRelative} from 'react-intl';

const Component = ({date, intl}) => (
<span title={intl.formatDate(date)}>
<FormattedRelative value={date}/>
</span>
<span title={intl.formatDate(date)}>
<FormattedRelative value={date} />
</span>
);

Component.propTypes = {
date: PropTypes.any.isRequired,
intl: intlShape.isRequired,
date: PropTypes.any.isRequired,
intl: intlShape.isRequired,
};

export default injectIntl(Component);
Expand Down Expand Up @@ -155,9 +155,9 @@ This function is exported by the `react-intl` package and provides an object-sha

The definition above shows what the `props.intl` object will look like that's injected to your component via `injectintl`. It's made up of three parts:

- __`IntlConfig`:__ The intl metadata passed as props into the parent `<IntlProvider>`.
- __`IntlFormat`:__ The imperative formatting API described below.
- __`now`:__ A function that returns the current time.
- **`IntlConfig`:** The intl metadata passed as props into the parent `<IntlProvider>`.
- **`IntlFormat`:** The imperative formatting API described below.
- **`now`:** A function that returns the current time.

### Date Formatting APIs

Expand Down Expand Up @@ -206,9 +206,9 @@ This function will return a formatted date string. It expects a `value` which ca

```js
formatDate(Date.now(), {
year: 'numeric',
month: 'numeric',
day: 'numeric',
year: 'numeric',
month: 'numeric',
day: 'numeric',
}); // "3/4/2016"
```

Expand All @@ -222,6 +222,7 @@ function formatTime(
```

This function will return a formatted date string, but it differs from [`formatDate`](#formatdate) by having the following default options:

```js
{
hour: 'numeric',
Expand Down Expand Up @@ -355,11 +356,13 @@ These APIs are used by their corresponding `<FormattedMessage>`, and `<Formatted
String/Message formatting is a paramount feature of React Intl and it builds on [ICU Message Formatting](http://userguide.icu-project.org/formatparse/messages) by using the [ICU Message Syntax](http://formatjs.io/guides/message-syntax/). This message syntax allows for simple to complex messages to be defined, translated, and then formatted at runtime.

**Simple Message:**

```
Hello, {name}
```

**Complex Message:**

```
Hello, {name}, you have {itemCount, plural,
=0 {no items}
Expand All @@ -374,15 +377,15 @@ Hello, {name}, you have {itemCount, plural,

React Intl has a Message Descriptor concept which is used to define your app's default messages/strings and is passed into `formatMessage` and `formatHTMLMessage`. The Message Descriptors work very well for providing the data necessary for having the strings/messages translated, and they contain the following properties:

- __`id`:__ A unique, stable identifier for the message
- __`description`:__ Context for the translator about how it's used in the UI
- __`defaultMessage`:__ The default message (probably in English)
- **`id`:** A unique, stable identifier for the message
- **`description`:** Context for the translator about how it's used in the UI
- **`defaultMessage`:** The default message (probably in English)

```js
type MessageDescriptor = {
id: string,
defaultMessage?: string,
description?: string | object,
id: string,
defaultMessage?: string,
description?: string | object,
};
```

Expand Down Expand Up @@ -415,11 +418,11 @@ If a translated message with the `id` has been passed to the `<IntlProvider>` vi

```js
const messages = defineMessages({
greeting: {
id: 'app.greeting',
defaultMessage: 'Hello, {name}!',
description: 'Greeting to welcome the user to the app',
},
greeting: {
id: 'app.greeting',
defaultMessage: 'Hello, {name}!',
description: 'Greeting to welcome the user to the app',
},
});

formatMessage(messages.greeting, {name: 'Eric'}); // "Hello, Eric!"
Expand All @@ -444,6 +447,6 @@ function formatHTMLMessage(

The React components provided by React Intl allow for a declarative, idiomatic-React way of providing internationalization configuration and format dates, numbers, and strings/messages in your app.

**See:** The [Components][Components] page.
**See:** The [Components][components] page.

[Components]: Components.md
[components]: Components.md