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

how can I dynamically change locale via i18n #377

Open
onethps opened this issue May 9, 2024 · 0 comments
Open

how can I dynamically change locale via i18n #377

onethps opened this issue May 9, 2024 · 0 comments

Comments

@onethps
Copy link

onethps commented May 9, 2024

How can I dynamically change locale via i18n?
The locale only changes when i restart application

import moment from 'moment';
import 'moment/locale/cs';
import 'moment/locale/de';
import 'moment/locale/es';
import 'moment/locale/pt';
import 'moment/locale/uk';
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import CalendarStrip from 'react-native-calendar-strip';


import { COLORS } from '@app/theme/constants/COLORS';

import { styles } from './styles';

export function LinearCalendar(props) {
  const {
    markedDates,
    onDateSelected,
    selectedDate,
    datesBlacklist,
    showMarketDates,
    hideArrows,
    ...rest
  } = props;

  const { t, i18n } = useTranslation();
  moment.locale(i18n.language);

  const markedDatesArray = showMarketDates ? getMarkedByOrderDates(markedDates) : null;

  return (
    <CalendarStrip
      selectedDate={selectedDate ?? {}}
      // minDate={moment(new Date()).subtract(3, 'days')}
      maxDate={moment(new Date()).add(1, 'y')}
      disabledDateOpacity={1}
      onDateSelected={onDateSelected}
      customDatesStyles={customDatesStyles}
      datesBlacklist={datesBlacklist}
      scrollable
      markedDates={markedDatesArray}
      dateNameStyle={styles.dateNameStyle}
      dateNumberStyle={styles.dateNumberStyle}
      highlightDateNameStyle={styles.highlightDateNameStyle}
      highlightDateNumberStyle={styles.highlightDateNumberStyle}
      highlightDateContainerStyle={styles.highlightDateContainerStyle}
      disabledDateNameStyle={styles.disabledDateNameStyle}
      iconStyle={styles.iconStyle}
      disabledDateNumberStyle={styles.disabledDateNumberStyle}
      iconContainer={styles.iconContainer}
      calendarHeaderStyle={styles.calendarHeaderStyle}
      style={styles.style}
      calendarColor="transparent"
      dayComponentHeight={100}
      maxDayComponentSize={200}
      // default names
      {...rest}
    />
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant