forked from jquense/yup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jquense#105 from grsabreu/master
Support custom locale
- Loading branch information
Showing
8 changed files
with
112 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
exports.__esModule = true; | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
exports.setLocale = setLocale; | ||
exports.getLocale = getLocale; | ||
var dict = {}; | ||
|
||
function setLocale(custom) { | ||
return dict = _extends({}, dict, custom); | ||
} | ||
|
||
function getLocale() { | ||
return dict; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let dict = {} | ||
|
||
export function setLocale(custom){ | ||
return (dict = { ...dict, ...custom }) | ||
} | ||
|
||
export function getLocale(){ | ||
return dict | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setLocale, getLocale } from '../src/customLocale' | ||
|
||
describe('Custom locale', () => { | ||
it('should set a new locale', () => { | ||
const dict = { | ||
string: { | ||
email: 'Invalid email', | ||
}, | ||
} | ||
|
||
setLocale(dict) | ||
|
||
expect(getLocale()).to.deep.equal(dict) | ||
}) | ||
|
||
it('should update the main locale', () => { | ||
const locale = require('../src/locale').default | ||
expect(locale.string).to.deep.include(getLocale().string) | ||
}) | ||
}) |