How to use localization?
SaeedZhiany opened this issue · comments
I can not change calendar localization, please provide more detail on this subject, in your wiki.
where exactly I must put this code?
import Moment from 'moment';
Moment.locales('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
weekdaysParseExact : true,
});
Please refer to Moment and MomentJalaali docs.
jMoment.loadPersian({dialect: 'persian-modern'})
I try that and what document mentioned, but nothing happens! please provide a detailed example if it's possible. or edit code below. what I'm doing wrong?
import {Calendar, CalendarList, Agenda} from 'react-native-general-calendars';
import Moment from 'moment-jalali';
type Props = {};
export default class App extends Component<Props> {
constructor() {
super();
Moment.loadPersian({dialect: 'persian-modern'});
}
render() {
//Moment.loadPersian({dialect: 'persian-modern'});
return (
<View style={styles.container}>
<Calendar
type="jalaali"
onDayPress={(day, localDay) => {
console.log('selected day', day, localDay)
}}
// Handler which gets executed when press arrow icon left. It receive a callback can go back month
onPressArrowLeft={substractMonth => substractMonth()}
// Handler which gets executed when press arrow icon left. It receive a callback can go next month
onPressArrowRight={addMonth => addMonth()}
/>
</View>
);
}
}
if the pull request #13 has been merged, user can switch between localizations in his/her code, here an example:
const jMoment = require('moment-jalaali');
.
.
.
jMoment.locale('en'); // for english localization
or
jMoment.loadPersian({dialect: 'persian-modern'}); // for persian localization