2017-06-01 11:49:32 +09:00
|
|
|
import React, { Component } from 'react';
|
2018-10-20 15:55:38 +09:00
|
|
|
import { getString } from 'meteor/vulcan:lib';
|
2017-06-01 11:49:32 +09:00
|
|
|
import { intlShape } from './shape.js';
|
|
|
|
|
|
|
|
export default class IntlProvider extends Component{
|
|
|
|
|
2018-04-21 17:58:25 +09:00
|
|
|
formatMessage = ({ id, defaultMessage }, values) => {
|
2018-10-20 15:55:38 +09:00
|
|
|
return getString({ id, defaultMessage, values, locale: this.props.locale });
|
2017-06-01 11:49:32 +09:00
|
|
|
}
|
|
|
|
|
2018-04-21 17:58:25 +09:00
|
|
|
formatStuff = (something) => {
|
2017-06-01 11:49:32 +09:00
|
|
|
return something;
|
|
|
|
}
|
|
|
|
|
|
|
|
getChildContext() {
|
|
|
|
return {
|
|
|
|
intl: {
|
|
|
|
formatDate: this.formatStuff,
|
|
|
|
formatTime: this.formatStuff,
|
|
|
|
formatRelative: this.formatStuff,
|
|
|
|
formatNumber: this.formatStuff,
|
|
|
|
formatPlural: this.formatStuff,
|
|
|
|
formatMessage: this.formatMessage,
|
|
|
|
formatHTMLMessage: this.formatStuff,
|
|
|
|
now: this.formatStuff,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render(){
|
|
|
|
return this.props.children;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
IntlProvider.childContextTypes = {
|
|
|
|
intl: intlShape
|
2018-01-25 15:03:03 -06:00
|
|
|
}
|