You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-25Lines changed: 49 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,41 @@
1
1
# react-globalize
2
2
3
-
Easy to use [React](http://facebook.github.io/react/)components that provide internationalization features out of the box via [Globalize](https://github.com/jquery/globalize). With a quick update of a value, variable or locale, you get instant UI updates.
3
+
Easy to use [React](http://facebook.github.io/react/)mixins that provide internationalization features to any React component via [Globalize](https://github.com/jquery/globalize). With a little initialization, you get instantly internationalized values in your components.
3. Then follow the usage instructions for each component below
10
-
11
-
## Components
12
-
Components are the heart of React and the whole point of react-globalize. These components provide simple, easily updatable elements in your page to display things like currency, dates, numbers and messages, formatted or translated to the current locale set by your application.
13
-
14
-
### FormatCurrency
8
+
```JS
9
+
var ReactGlobalize = require('react-globalize');
10
+
var Globalize = require('globalize');
11
+
12
+
// Initialize Globalize and load your CLDR data
13
+
// See https://github.com/jquery/globalize for details on Globalize usage
14
+
15
+
// In your component, this example just places the formatted value in a span
3. Further info about each mixin and its available props below
34
+
35
+
## Mixins
36
+
These mixins provide a simple way to display things like currency, dates, numbers and messages, formatted or translated to the current locale set by your application. Each mixin has a set of props, both required and optional, to be included in your component. The mixin then uses the values of those props, to add a `formattedValue` to your component's state. Below is a listing of each mixin, its props and a usage example.
37
+
38
+
### formatCurrency
15
39
#### Props
16
40
-**locale** - required
17
41
- A string value representing the CLDR indicator for the desired locale used in formatting the amount. Most apps will pull this value from the component's state or the state of one of its parent compenents.
@@ -22,20 +46,20 @@ Components are the heart of React and the whole point of react-globalize. These
22
46
-**options**
23
47
- An optional set of options to further format the value. See the [numberFormatter](https://github.com/jquery/globalize/blob/master/doc/api/number/number-formatter.md) docs in Globalize for more info on specific options
24
48
25
-
#### Usage
49
+
#### Usage via an example FormatCurrency component
- A string value representing the CLDR indicator for the desired locale used in formatting the date. Most apps will pull this value from the component's state or the state of one of its parent compenents.
@@ -44,20 +68,20 @@ Result: (€150,00)
44
68
-**pattern** - required
45
69
- An string or object which defines how to format the date. See the [dateFormatter](https://github.com/jquery/globalize/blob/master/doc/api/date/date-formatter.md) docs in Globalize for more info on supported patterns
Result: this.state.formattedValue = 27 de fev de 2015 11:17:10
59
83
60
-
### FormatMessage
84
+
### formatMessage
61
85
#### Props
62
86
-**locale** - required
63
87
- A string value representing the CLDR indicator for the desired locale used in formatting the message. Most apps will pull this value from the component's state or the state of one of its parent compenents.
@@ -66,7 +90,7 @@ Result: 27 de fev de 2015 11:17:10
66
90
-**variables**
67
91
- An array (where variables are represented as indeces) or object (for named variables) which contains values for variable replacement within a message.
68
92
69
-
#### Usage
93
+
#### Usage via an example FormatMessage component
70
94
Below message JSON used in these examples:
71
95
```JS
72
96
{
@@ -96,23 +120,23 @@ Below message JSON used in these examples:
96
120
97
121
Hi in English: `<FormatMessage locale="en" path="salutations/hi" />`
98
122
99
-
Result: Hi
123
+
Result: this.state.formattedValue = Hi
100
124
101
125
Hi in Portuguese: `<FormatMessage locale="pt-BR" path="salutations/hi" />`
102
126
103
-
Result: Oi
127
+
Result: this.state.formattedValue = Oi
104
128
105
129
- Variable Replacement
106
130
107
131
Array in English: `<FormatMessage locale="en" path="variables/hello" variables={["Wolfgang", "Amadeus", "Mozart"]} />`
108
132
109
-
Result: Hello, Wolfgang Amadeus Mozart
133
+
Result: this.state.formattedValue = Hello, Wolfgang Amadeus Mozart
110
134
111
135
Object in Portuguese: `<FormatMessage locale="pt-BR" path="variables/hey" variables={{first:"Wolfgang", middle:"Amadeus", last:"Mozart"}} />`
112
136
113
-
Result: Ei, Wolfgang Amadeus Mozart
137
+
Result: this.state.formattedValue = Ei, Wolfgang Amadeus Mozart
114
138
115
-
### FormatNumber
139
+
### formatNumber
116
140
#### Props
117
141
-**locale** - required
118
142
- A string value representing the CLDR indicator for the desired locale used in formatting the date. Most apps will pull this value from the component's state or the state of one of its parent compenents.
@@ -121,18 +145,18 @@ Result: Ei, Wolfgang Amadeus Mozart
121
145
-**options**
122
146
- An optional set of options to further format the value. See the [numberFormatter](https://github.com/jquery/globalize/blob/master/doc/api/number/number-formatter.md) docs in Globalize for more info on specific options
0 commit comments