Skip to content

Commit 0d595e7

Browse files
Merge pull request #1 from aboutbits/it-de-en
Custom Yup locale translations for IT, DE and EN
2 parents 8d877a7 + 9b8e0ae commit 0d595e7

14 files changed

Lines changed: 463 additions & 0 deletions

File tree

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
it.js
2+
it.d.ts
3+
de.js
4+
de.d.ts
5+
en.js
6+
en.d.ts

.eslintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"env": {
4+
"node": true,
5+
"browser": true,
6+
"es6": true,
7+
"commonjs": true
8+
},
9+
"plugins": [
10+
"@typescript-eslint",
11+
"import",
12+
"prettier"
13+
],
14+
"extends": [
15+
"plugin:@typescript-eslint/recommended",
16+
"plugin:prettier/recommended",
17+
"plugin:import/recommended",
18+
"plugin:import/typescript",
19+
"plugin:jest/recommended"
20+
],
21+
"parserOptions": {
22+
"sourceType": "module",
23+
"ecmaVersion": 2018
24+
},
25+
"rules": {
26+
"@typescript-eslint/no-unused-vars": "error",
27+
"@typescript-eslint/member-delimiter-style": "off",
28+
"@typescript-eslint/explicit-function-return-type": "off",
29+
"import/order": [
30+
"error",
31+
{
32+
"groups": ["builtin", "external", "unknown", "parent", "sibling", "index"]
33+
}
34+
]
35+
}
36+
}

.githooks/pre-commit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
npm run lint

.github/workflows/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Create Relase & Publish Package
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/create-release@v1
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
with:
15+
tag_name: ${{ github.ref }}
16+
release_name: Release ${{ github.ref }}
17+
draft: false
18+
prerelease: false
19+
- uses: actions/setup-node@v1
20+
with:
21+
node-version: '16.x'
22+
registry-url: 'https://registry.npmjs.org'
23+
- run: npm ci
24+
- run: npm publish
25+
env:
26+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Basic
2+
.DS_Store
3+
4+
# IDE
5+
/.idea
6+
/.vscode
7+
8+
# Project
9+
/package-lock.json
10+
/node_modules
11+
/dist
12+
13+
it.js
14+
it.d.ts
15+
de.js
16+
de.d.ts
17+
en.js
18+
en.d.ts

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}

jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
3+
transform: {
4+
'^.+\\.tsx?$': 'babel-jest',
5+
},
6+
moduleNameMapper: {
7+
'\\.(css)$': 'identity-obj-proxy',
8+
},
9+
}

package.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"name": "@aboutbits/yup-locales",
3+
"version": "0.0.0",
4+
"description": "Custom yup locales",
5+
"keywords": [
6+
"yup",
7+
"internationalization",
8+
"language",
9+
"languages"
10+
],
11+
"author": "AboutBits",
12+
"license": "MIT",
13+
"private": false,
14+
"main": "en.js",
15+
"typings": "en.d.ts",
16+
"scripts": {
17+
"build": "tsc",
18+
"lint": "eslint --ext js,ts,tsx src",
19+
"lint:fix": "npm run lint -- --fix",
20+
"test": "jest --config jest.config.js --passWithNoTests",
21+
"prepare": "npm run build",
22+
"prepublishOnly": "npm run test && npm run lint",
23+
"version": "npm run test && npm run lint && git add -A src",
24+
"postversion": "git push && git push --tags"
25+
},
26+
"repository": {
27+
"type": "git",
28+
"url": "git+https://github.com/aboutbits/yup-locales.git"
29+
},
30+
"files": [
31+
"readme.md",
32+
"it.js",
33+
"it.d.ts",
34+
"de.js",
35+
"de.d.ts",
36+
"en.js",
37+
"en.d.ts"
38+
],
39+
"publishConfig": {
40+
"access": "public"
41+
},
42+
"bugs": {
43+
"url": "https://github.com/aboutbits/yup-locales/issues"
44+
},
45+
"homepage": "https://github.com/aboutbits/yup-locales#readme",
46+
"engines": {
47+
"npm": "^8",
48+
"node": "^16"
49+
},
50+
"devDependencies": {
51+
"@types/jest": "^28.1.3",
52+
"@types/node": "^16.0.0",
53+
"@typescript-eslint/eslint-plugin": "^5.29.0",
54+
"@typescript-eslint/parser": "^5.29.0",
55+
"babel-jest": "^28.1.1",
56+
"babel-loader": "^8.2.5",
57+
"eslint": "^8.18.0",
58+
"eslint-config-prettier": "^8.5.0",
59+
"eslint-plugin-import": "^2.26.0",
60+
"eslint-plugin-jest": "^26.5.3",
61+
"eslint-plugin-prettier": "^4.0.0",
62+
"jest": "^28.1.1",
63+
"prettier": "^2.7.1",
64+
"typescript": "^4.7.4",
65+
"yup": "^0.32.11"
66+
}
67+
}

readme.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Custom Yup Locales
2+
====================
3+
4+
[![npm version](https://badge.fury.io/js/%40aboutbits%2Fyup-locales.svg)](https://badge.fury.io/js/%40aboutbits%2Fyup-locales)
5+
6+
This package includes simplified translations for yup error messages. The main difference lies in the exclusion of the field path.
7+
8+
## Table of content
9+
10+
- [Usage](#usage)
11+
- [Build & Publish](#build--publish)
12+
- [Information](#information)
13+
14+
## Usage
15+
16+
First, you have to install the package:
17+
18+
```bash
19+
npm install @aboutbits/yup-locales
20+
```
21+
22+
Second, you add the custom language packages to your project.
23+
24+
```js
25+
import { setLocale } from 'yup'
26+
import { en, it, de } from '@aboutbits/yup-locales'
27+
28+
// If you want that your app returns Italian error messages.
29+
setLocale(it)
30+
```
31+
32+
## Build & Publish
33+
34+
To build and publish the package, simply commit all changes and push them to master. Then run one of the following commands locally:
35+
36+
```bash
37+
npm version patch
38+
npm version minor
39+
npm version major
40+
```
41+
42+
## Information
43+
44+
About Bits is a company based in South Tyrol, Italy. You can find more information about us on [our website](https://aboutbits.it).
45+
46+
### Support
47+
48+
For support, please contact [info@aboutbits.it](mailto:info@aboutbits.it).
49+
50+
### Credits
51+
52+
- [All Contributors](../../contributors)
53+
54+
### License
55+
56+
The MIT License (MIT). Please see the [license file](LICENSE.md) for more information.

0 commit comments

Comments
 (0)