- implement i18n

- translation dynamic for sections
- added articles for SEO
This commit is contained in:
Amruth Pillai
2020-07-16 08:42:19 +05:30
parent b7c565de79
commit a7657b4a5c
74 changed files with 2373 additions and 586 deletions

View File

@ -1,8 +1,12 @@
import { get, isEmpty } from 'lodash';
import moment from 'moment';
import { useTranslation } from 'react-i18next';
export const getModalText = (isEditMode, type) => {
return isEditMode ? `Edit ${type}` : `Add ${type}`;
const { t } = useTranslation();
return isEditMode
? `${t('shared.buttons.edit')} ${type}`
: `${t('shared.buttons.add')} ${type}`;
};
export const safetyCheck = (section, path = 'items') => {
@ -30,6 +34,11 @@ export const getFieldProps = (formik, schema, name) => ({
...formik.getFieldProps(name),
});
export const getUnsplashPhoto = async () => {
const response = await fetch('https://source.unsplash.com/featured/400x600');
return response.url;
};
export const hexToRgb = (hex) => {
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);