Skip to content

Commit 4f0f173

Browse files
rxavierskborchers
authored andcommitted
Support either global or local locale
The global locale should be set by using `Globalize.locale()` prior to the rendering. A local locale should be set via a property `locale` in the React component.
1 parent be19b50 commit 4f0f173

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
99

1010
(function(currentFn, currentArgs) {
1111
var formatter = function(nextProps) {
12+
var instance = Globalize;
1213
var componentProps = nextProps || this.props;
1314
var propArgs = currentArgs.map(function(element) {
1415
return componentProps[element.replace(/(\s\/\*|\*\/)/,"").trim()];
1516
});
1617

17-
Globalize.locale( componentProps["locale"] );
18+
if (componentProps["locale"]) {
19+
instance = Globalize(componentProps["locale"]);
20+
}
1821
this.setState({
19-
formattedValue: Globalize[currentFn].apply(Globalize, propArgs)
22+
formattedValue: instance[currentFn].apply(instance, propArgs)
2023
});
2124
};
2225

@@ -27,4 +30,5 @@ Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
2730
})(fn, argArray);
2831
}
2932
});
33+
3034
module.exports = mixins;

0 commit comments

Comments
 (0)