mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-08 07:03:23 -06:00
Add code to enable localisation.
This commit is contained in:
parent
e77a1e403f
commit
5850c5e20a
27
resources/assets/js/app.js
vendored
27
resources/assets/js/app.js
vendored
@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* First we will load all of this project's JavaScript dependencies which
|
||||
* includes Vue and other libraries. It is a great starting point when
|
||||
@ -8,11 +7,15 @@
|
||||
require('./bootstrap');
|
||||
window.Vue = require('vue');
|
||||
|
||||
|
||||
import moment from 'moment';
|
||||
import accounting from 'accounting';
|
||||
import Lang from './lang.js';
|
||||
|
||||
Vue.filter('formatDate', function(value) {
|
||||
Vue.filter('trans', (...args) => {
|
||||
return Lang.get(...args);
|
||||
});
|
||||
|
||||
Vue.filter('formatDate', function (value) {
|
||||
|
||||
if (value) {
|
||||
moment.locale(window.language);
|
||||
@ -20,22 +23,21 @@ Vue.filter('formatDate', function(value) {
|
||||
}
|
||||
});
|
||||
|
||||
Vue.filter('formatAmount', function(value) {
|
||||
Vue.filter('formatAmount', function (value) {
|
||||
if (value) {
|
||||
value = parseFloat(value);
|
||||
var parsed = accounting.formatMoney(value, window.currencySymbol, window.frac_digits,window.mon_thousands_sep,window.mon_decimal_point,accountingConfig);
|
||||
if(value < 0) {
|
||||
let parsed = accounting.formatMoney(value, window.currencySymbol, window.frac_digits, window.mon_thousands_sep, window.mon_decimal_point, accountingConfig);
|
||||
if (value < 0) {
|
||||
return '<span class="text-danger">' + parsed + '</span>';
|
||||
}
|
||||
if(value > 0) {
|
||||
return '<span class="text-success">' + parsed + '</span>';
|
||||
if (value > 0) {
|
||||
return '<span class="text-success">' + parsed + '</span>';
|
||||
}
|
||||
return '<span style="color:#999;">' + parsed + '</span>';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Next, we will create a fresh Vue application instance and attach it to
|
||||
* the page. Then, you may begin adding components to this application
|
||||
@ -62,9 +64,6 @@ Vue.component(
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const app = new Vue({
|
||||
el: '#app'
|
||||
});
|
||||
el: '#app'
|
||||
});
|
||||
|
30
resources/assets/js/lang.js
vendored
Normal file
30
resources/assets/js/lang.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* lang.js
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Inside my /resources/assets/js/lang.js
|
||||
import lang from 'lang.js';
|
||||
import messages from './messages';
|
||||
|
||||
const Lang = new lang({messages});
|
||||
|
||||
Lang.setLocale(window.language);
|
||||
Lang.setFallback('en_US');
|
||||
|
||||
export default Lang;
|
1
resources/assets/js/messages.js
vendored
Normal file
1
resources/assets/js/messages.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user