0

私は反応日付で作業しており、月と曜日の名前を国際化する方法を見つけようとしています。入力プレースホルダーテキストに対してこれを行う方法はすでにわかっていますが、これを行う方法が見つかりません。

反応日付に与える現在の小道具は次のDateRangePickerようになります。

<DateRangePicker
        startDate={this.state.startDate} // momentPropTypes.momentObj or null,
        endDate={this.state.endDate} // momentPropTypes.momentObj or null,
        onDatesChange={({ startDate, endDate }) => {
            this.setState({ startDate, endDate });
            this.props.onDateChange(this.props.name, startDate, endDate);
          }
        } // PropTypes.func.isRequired,
        focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
        onFocusChange={focusedInput => this.setState({ focusedInput })} // PropTypes.func.isRequired,
        numberOfMonths={1}
        firstDayOfWeek={1}
        minimumNights={0}
        isOutsideRange={(x) => moment().add(1, 'days') < x }
        displayFormat="DD-MM-YYYY"
        showClearDates={true}
        startDatePlaceholderText={this.props.intl.formatMessage({id: 'DATE_PICKER_START_DATE'})}
        endDatePlaceholderText={this.props.intl.formatMessage({id: 'DATE_PICKER_END_DATE'})}
        hideKeyboardShortcutsPanel= {true}
      />

react-intl国際化のために使用しています。

これは、カレンダーがどのように見えるかです: カレンダーの画像

基本的に変えたいのは月名Novemberと曜日名Mo Tu We Th Fr Sa Su

望ましい結果は、それらをフィンランド語に翻訳することです ->MarraskuuそしてMa Ti Ke To Pe La Su

4

1 に答える 1

1

私はフィンランド語で瞬間をインポートし、datepicker にいくつかの追加の小道具を追加することで、これを解決することができました。

import React, { Component } from "react";
import {DateRangePicker} from 'react-dates';
import { injectIntl, intlShape } from "react-intl";
import moment from 'moment'
import 'moment/locale/fi';
import 'react-dates/initialize';
import 'react-dates/lib/css/_datepicker.css';

.
.
.

<DateRangePicker
    .
    .
    .
    renderMonthText={month => {
      month.locale(this.props.intl.locale)
      return(
        moment(month).format('MMMM YYYY')
      )
    }}
    renderDayContents={day => {
      day.local(this.props.intl.local)
      return(
        moment(day).format('D')
      )
    }}
  />
于 2019-01-24T07:42:16.317 に答える