Skip to content

Commit

Permalink
refactor(dependencies): add dependencies from base to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Giorgiosaud committed Mar 17, 2020
1 parent 62684ff commit 59b1721
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/dist
storybook-static

.vscode
# local env files
.env.local
.env.*.local
Expand Down
Binary file removed src/assets/logo.png
Binary file not shown.
39 changes: 39 additions & 0 deletions src/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Config file for i18n plugin */

import Vue from 'vue';
import VueI18n from 'vue-i18n';

// The default language is spanish.
// If you add another language to your project be sure to:
// STEP 1: import the validations messages from vee-validate.
import esCL from 'vee-validate/dist/locale/es.json';

Vue.use(VueI18n);

function loadLocaleMessages() {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i);
const messages = {};
locales.keys().forEach((key) => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i);
if (matched && matched.length > 1) {
const locale = matched[1];
messages[locale] = locales(key);
}
});

// STEP 2: add the validation messages to the i18n plugin.
// Copy the code below for every new language you add.
messages['es-CL'] = {
...messages['es-CL'],
validations: esCL.messages,
};


return messages;
}

export default new VueI18n({
locale: 'es-CL',
fallbackLocale: 'es-CL',
messages: loadLocaleMessages(),
});
3 changes: 3 additions & 0 deletions src/locales/es-CL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"progress-message": "Has utilizado el {0}% de tu cupo."
}
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Vue from 'vue';
import App from './App.vue';
import i18n from './i18n';
import './vee-validate-config';
import 'bootstrap';

import 'bootstrap/dist/css/bootstrap.min.css';

Vue.config.productionTip = false;

new Vue({
i18n,
render: (h) => h(App),
}).$mount('#app');
30 changes: 30 additions & 0 deletions src/vee-validate-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable camelcase */
/* eslint-disable no-underscore-dangle */

/* Config file for VeeValidate */
/* Import and extend the rules you need to use. */

import {
extend,
configure,
} from 'vee-validate';
import {
required,
email,
numeric,
min_value,
max_value,
} from 'vee-validate/dist/rules';


import i18n from './i18n';

configure({
defaultMessage: (_, values) => i18n.t(`validations.${values._rule_}`, values),
});

extend('required', required);
extend('email', email);
extend('numeric', numeric);
extend('min_value', min_value);
extend('max_value', max_value);

0 comments on commit 59b1721

Please sign in to comment.