mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: yup locale.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { setLocale } from 'yup';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { find } from 'lodash';
|
import { find } from 'lodash';
|
||||||
import rtlDetect from 'rtl-detect';
|
import rtlDetect from 'rtl-detect';
|
||||||
@@ -32,6 +33,10 @@ function loadLocales(currentLocale) {
|
|||||||
return import(`../lang/${currentLocale}/index.json`);
|
return import(`../lang/${currentLocale}/index.json`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadYupLocales(currentLocale) {
|
||||||
|
return import(`../lang/${currentLocale}/locale`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the html document direction to RTl if it was rtl-language.
|
* Modifies the html document direction to RTl if it was rtl-language.
|
||||||
*/
|
*/
|
||||||
@@ -74,6 +79,14 @@ export default function AppIntlLoader({ children }) {
|
|||||||
});
|
});
|
||||||
}, [currentLocale, setIsLoading]);
|
}, [currentLocale, setIsLoading]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
loadYupLocales(currentLocale)
|
||||||
|
.then(({ locale }) => {
|
||||||
|
setLocale(locale);
|
||||||
|
})
|
||||||
|
.then(() => {});
|
||||||
|
}, [currentLocale]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardLoadingIndicator isLoading={isLoading}>
|
<DashboardLoadingIndicator isLoading={isLoading}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
|
|||||||
import { Button, Intent } from '@blueprintjs/core';
|
import { Button, Intent } from '@blueprintjs/core';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import WorkflowIcon from './WorkflowIcon';
|
import WorkflowIcon from './WorkflowIcon';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'components';
|
||||||
import withOrganizationActions from 'containers/Organization/withOrganizationActions';
|
import withOrganizationActions from 'containers/Organization/withOrganizationActions';
|
||||||
|
|
||||||
import 'style/pages/Setup/Congrats.scss';
|
import 'style/pages/Setup/Congrats.scss';
|
||||||
|
|||||||
64
client/src/lang/ar-ly/locale.js
Normal file
64
client/src/lang/ar-ly/locale.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
// Based on https://github.com/jquense/yup/blob/2973d0a/src/locale.js
|
||||||
|
|
||||||
|
import printValue from '../printValue';
|
||||||
|
|
||||||
|
export const locale = {
|
||||||
|
mixed: {
|
||||||
|
default: '${path} غير صالح.',
|
||||||
|
required: '${path} هو حقل مطلوب',
|
||||||
|
oneOf: '${path} يجب أن تكون واحدة من القيم التالية: ${values}',
|
||||||
|
notOneOf: '${path} لا يجب أن تكون واحدة من القيم التالية: ${values}',
|
||||||
|
notType: ({ path, type, value, originalValue }) => {
|
||||||
|
const isCast = originalValue != null && originalValue !== value;
|
||||||
|
let msg =
|
||||||
|
`${path} يجب أن يكون \`${type}\` نوع, ` +
|
||||||
|
`ولكن القيمة النهائية كانت في: \`${printValue(value, true)}\`` +
|
||||||
|
(isCast
|
||||||
|
? ` (المدلى بها من قيمة \`${printValue(originalValue, true)}\`).`
|
||||||
|
: '.');
|
||||||
|
|
||||||
|
if (value === null) {
|
||||||
|
msg +=
|
||||||
|
`\n إذا كان المقصود "لاغية" كقيمة فارغة مما لا شك فيه للاحتفال مخطط كما` +
|
||||||
|
' `.nullable()`';
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
string: {
|
||||||
|
length: '${path} يجب أن يكون بالضبط ${length} حرفا',
|
||||||
|
min: '${path} يجب أن تكون على الأقل ${min} حرفا',
|
||||||
|
max: '${path} يجب أن تكون على الأكثر ${max} حرفا',
|
||||||
|
matches: '${path} يجب أن يطابق ما يلي: "${regex}"',
|
||||||
|
email: '${path} يجب أن يكون عنوان بريد إلكتروني صالح',
|
||||||
|
url: '${path} يجب أن يكون عنوان URL صالحا',
|
||||||
|
trim: '${path} يجب أن تكون سلسلة قلص',
|
||||||
|
lowercase: '${path} يجب أن تكون سلسلة صغيرة',
|
||||||
|
uppercase: '${path} يجب أن تكون سلسلة الحالة العلوي',
|
||||||
|
},
|
||||||
|
|
||||||
|
number: {
|
||||||
|
min: '${path} يجب أن تكون أكبر من أو يساوي ${min}',
|
||||||
|
max: '${path} يجب أن يكون أقل من أو يساوي ${max}',
|
||||||
|
lessThan: '${path} يجب أن يكون أقل من ${less}',
|
||||||
|
moreThan: '${path} يجب أن تكون أكبر من ${more}',
|
||||||
|
positive: '${path} يجب أن يكون رقما موجبا',
|
||||||
|
negative: '${path} يجب أن يكون رقما سالبا',
|
||||||
|
integer: '${path} يجب أن يكون رقما',
|
||||||
|
},
|
||||||
|
date: {
|
||||||
|
min: '${path} يجب أن يكون حقل في وقت لاحق من ${min}',
|
||||||
|
max: '${path} يجب أن يكون حقل في وقت سابق من ${max}',
|
||||||
|
},
|
||||||
|
boolean: {},
|
||||||
|
|
||||||
|
object: {
|
||||||
|
noUnknown: '${path} حقل لا يمكن أن يكون مفاتيح غير محددة في شكل وجوه',
|
||||||
|
},
|
||||||
|
array: {
|
||||||
|
min: 'يجب أن يكون ${path} حقل على الأقل ${min} من العناصر',
|
||||||
|
max: '${path} يجب أن يكون الحقل أقل من أو يساوي إلى ${max} من العناصر',
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import printValue from '../printValue';
|
import printValue from '../printValue';
|
||||||
|
|
||||||
export const locale = {
|
export const locale = {
|
||||||
mixed: {
|
mixed: {
|
||||||
default: '${path} is invalid',
|
default: '${path} is invalid',
|
||||||
|
|||||||
Reference in New Issue
Block a user