const initI18N = () => { i18next.init({ lng: getLanguage(), resources: messages }) }
constructor(props) { super(props); i18n.on('languageChanged', (lng) => { // needed when language changes via path and to change path when language does not change via path rootStoreInstance.configStore.language = lng; rootStoreInstance.configStore.changeHistory(this.props.history, this.props.location); }); }
// Method helpers static get _Intl() { return { NumberFormat: new Intl.NumberFormat(i18next.language, { style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2 }), NumberFormatPercent: new Intl.NumberFormat(i18next.language, { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2 }), NumberFormatCurrency: new Intl.NumberFormat(i18next.language, { style: 'currency', currency: i18next.t('__currency_code') }) }; }
afterSetData(args) { const occupant = args[0]; $(domSelector + ' #occupantNameLabel').html(i18next.t('\'s documents', {name:occupant.name})); }
const Simple = () => ( <div> <h4>Simple Component</h4> <Sections t={i18next.t.bind(i18next)} /> </div> )
set language(language) { language = language.replace(/-[a-zA-Z]{2}/, ""); if (AVAILABLE_LANGUAGES.indexOf(language) < 0) { return; } if (language === this._language) { return; } this._language = language; i18n.changeLanguage(language) }
_companyChanged($select) { var selection = $select.find(':selected').val(); if (selection === 'true') { $('#occupant-form .private-fields').hide(); $('#occupant-form .js-company-fields').show(); $('#occupant-form #manager-label').html(i18next.t('Effective manager (first and last name)')); } else { $('#occupant-form .js-company-fields').hide(); $('#occupant-form .private-fields').show(); $('#occupant-form #manager-label').html(i18next.t('First and last name')); } }
// Change translation language export function changeLanguage(lng) { return i18next.changeLanguage(lng); }
// ISO2 to country name mappings export function co(ISO2) { return i18next.t(`countries:${ISO2}`); }
Handlebars.registerHelper('paymentBadgeStatus', function() { var html = ''; if (this.status === 'paid') { html = '<span class="label label-success" data-toggle="tooltip" data-placement="bottom" title="'+i18next.t('Paid')+'"><i class="fa fa-check"></i> '+moment.monthsShort()[parseInt(this.month, 10)-1].toUpperCase()+'</span>'; } else if (this.status === 'partialypaid') { html = '<span class="label label-warning" data-toggle="tooltip" data-placement="bottom" title="'+i18next.t('Partially paid')+'"><i class="fa fa-exclamation-triangle"></i> '+moment.monthsShort()[parseInt(this.month, 10)-1].toUpperCase()+'</span>'; } else if (this.status === 'notpaid') { html = '<span class="label label-danger" data-toggle="tooltip" data-placement="bottom" title="'+i18next.t('Not paid')+'"><i class="fa fa-exclamation-triangle"></i> '+moment.monthsShort()[parseInt(this.month, 10)-1].toUpperCase()+'</span>'; } return new Handlebars.SafeString(html); });
$.validator.addMethod('phoneFR', function(phone_number, element) { phone_number = phone_number.replace(/\(|\)|\s+|-/g, ''); return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(?:(?:(?:00\s?|\+)33\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/); }, i18next.t('Please enter a valid phone number'));
// Update moment js locale when language is changed i18next.on("languageChanged", lng => { moment.locale(lng); });
afterSetData(args) { const property = args[0]; if (property && property._id) { $(domSelector + ' #propertyNameLabel').html(property.name); $('.js-user-action[data-id="list-action-remove-property"]').show(); } else { $(domSelector + ' #propertyNameLabel').html(i18next.t('Property to rent')); $('.js-user-action[data-id="list-action-remove-property"]').hide(); } this._typeChanged($(domSelector + ' #type')); this._computeRent(); }
// Standard text string translations export function t(...args) { return i18next.t(...args); }
// ISO2 to currencies mappings export function cu(ISO2) { return i18next.t(`currencies:${ISO2}`); }