Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-missing-locales
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicMahieu authored Aug 1, 2024
2 parents 6cf48d5 + 9b4a5d6 commit 0064d8c
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Locales implemented:
- `fi`
- `fr`
- `he`
- `hu`
- `id`
- `it`
- `ja`
Expand Down
94 changes: 62 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,62 @@
export * as ar from './locales/ar';
export * as bg from './locales/bg';
export * as bs from './locales/bs';
export * as cs from './locales/cs';
export * as da from './locales/da';
export * as de from './locales/de';
export * as en from './locales/en';
export * as es from './locales/es';
export * as et from './locales/et';
export * as fi from './locales/fi';
export * as fr from './locales/fr';
export * as he from './locales/he';
export * as id from './locales/id';
export * as it from './locales/it';
export * as ja from './locales/ja';
export * as ko from './locales/ko';
export * as lt from './locales/lt';
export * as nb from './locales/nb';
export * as nl from './locales/nl';
export * as pl from './locales/pl';
export * as pt from './locales/pt';
export * as ro from './locales/ro';
export * as ru from './locales/ru';
export * as sk from './locales/sk';
export * as sv from './locales/sv';
export * as th from './locales/th';
export * as tr from './locales/tr';
export * as uk from './locales/uk';
export * as uz from './locales/uz';
export * as vi from './locales/vi';
export * as zh from './locales/zh';
export * as zhtw from './locales/zhtw'
import * as ar from './locales/ar';
import * as bg from './locales/bg';
import * as bs from './locales/bs';
import * as cs from './locales/cs';
import * as da from './locales/da';
import * as de from './locales/de';
import * as en from './locales/en';
import * as es from './locales/es';
import * as fr from './locales/fr';
import * as he from './locales/he';
import * as hu from './locales/hu';
import * as hu from './locales/hu';
import * as id from './locales/id';
import * as it from './locales/it';
import * as ja from './locales/ja';
import * as ko from './locales/ko';
import * as lt from './locales/lt';
import * as nb from './locales/nb';
import * as nl from './locales/nl';
import * as pl from './locales/pl';
import * as pt from './locales/pt';
import * as ru from './locales/ru';
import * as sk from './locales/sk';
import * as th from './locales/th';
import * as tr from './locales/tr';
import * as uz from './locales/uz';
import * as vi from './locales/vi';
import * as zh from './locales/zh';
import * as zhtw from './locales/zhtw';
import * as ro from './locales/ro';

export {
ar,
bg,
bs,
cs,
da,
de,
en,
es,
fr,
he,
hu,
id,
it,
ja,
ko,
lt,
nb,
nl,
pl,
pt,
ro,
ru,
sk,
th,
tr,
uz,
vi,
zh,
zhtw,
};
74 changes: 74 additions & 0 deletions src/locales/hu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*eslint-disable no-template-curly-in-string*/

import { printValue, LocaleObject } from 'yup';

// Based on https://github.com/jquense/yup/blob/b940eef48eb7456622ae384d0ffa7363d4fbad25/src/locale.ts
export const mixed: LocaleObject['mixed'] = {
default: 'A ${path} érvénytelen.',
required: 'A ${path} egy szükséges mező',
defined: '${path} meg kell határozni',
notNull: '${path} nem lehet nulla',
oneOf: '${path} a következő értékek egyikének kell lennie: ${values}',
notOneOf: '${path} nem lehet a következő értékek egyike: ${values}',
notType: ({ path, type, value, originalValue }) => {
const isCast = originalValue != null && originalValue !== value;
let msg =
`${path} "${type}" típusnak kell lennie, ` +
`De a végső érték a következő volt: \`${printValue(value, true)}\`` +
(isCast
? ` (a „${printValue(originalValue, true)}” értékből öntött).`
: '.');

if (value === null) {
msg +=
`\n Ha a "null" üres értéknek szánják, feltétlenül jelölje meg a sémát` +
' `.nullable()`';
}

return msg;
},
};

export const string: LocaleObject['string'] = {
length: '${path} pontosan ${length} karaktereknek kell lennie',
min: '${path} legalább ${min} karaktereknek kell lennie',
max: '${path} legfeljebb ${max} karaktereknek kell lennie',
matches: '${path} meg kell egyeznie a következőkkel: "${regex}"',
email: '${path} érvényes e -mailnek kell lennie',
url: '${path} érvényes URL -nek kell lennie',
uuid: '${path} érvényes UUID -nak kell lennie',
trim: 'A ${path} -nak vágott karakterláncnak kell lennie',
lowercase: '${path} kisbetűs karakterláncnak kell lennie',
uppercase: 'A ${path} -nak felsőfokú karakterláncnak kell lennie',
};

export const number: LocaleObject['number'] = {
min: '${path} nagyobbnak vagy egyenlőnek kell lennie ${min}',
max: 'A ${path} -nak kevesebbnek vagy egyenlőnek kell lennie ${max}',
lessThan: 'A ${path} -nak kevesebbnek kell lennie, mint a ${less}',
moreThan: '${path} nagyobbnak kell lennie, mint a ${more}',
positive: '${path} pozitív számnak kell lennie',
negative: '${path} negatív számnak kell lennie',
integer: '${path} egész számnak kell lennie',
};

export const date: LocaleObject['date'] = {
min: '${path} A mezőnek később kell lennie, mint a ${min}',
max: '${path} A mezőnek korábban kell lennie, mint a ${max}',
};

export const boolean: LocaleObject['boolean'] = {
isValue: '${path} A mezőnek ${value} -nak kell lennie',
};

export const object: LocaleObject['object'] = {
noUnknown:
'${path} A mezőnek nem lehet olyan kulcsok, amelyek nem adják meg az objektum alakjában',
};

export const array: LocaleObject['array'] = {
min: '${path} A mezőnek legalább ${min} tételekkel kell rendelkeznie',
max:
'${path} A mezőnek kevesebbnek vagy egyenlőnek kell lennie a ${max} tételekkel',
length: '${path} ${length} tételekkel kell rendelkeznie',
};

0 comments on commit 0064d8c

Please sign in to comment.