mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-11 09:29:34 +00:00
Clean up languages [skip ci]
This commit is contained in:
@@ -55,7 +55,6 @@ export default () => ({
|
||||
this.boxData = response.data;
|
||||
window.store.set(boxesCacheKey, response.data);
|
||||
this.generateOptions(this.boxData);
|
||||
//this.drawChart();
|
||||
});
|
||||
},
|
||||
generateOptions(data) {
|
||||
|
||||
@@ -22,17 +22,15 @@ import Dashboard from "../../api/v2/chart/budget/dashboard.js";
|
||||
import {getDefaultChartSettings} from "../../support/default-chart-settings.js";
|
||||
import formatMoney from "../../util/format-money.js";
|
||||
import {Chart} from 'chart.js';
|
||||
import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {getColors} from "../../support/get-colors.js";
|
||||
import {getCacheKey} from "../../support/get-cache-key.js";
|
||||
import i18next from "i18next";
|
||||
|
||||
let currencies = [];
|
||||
let chart = null;
|
||||
let chartData = null;
|
||||
let afterPromises = false;
|
||||
|
||||
let i18n; // for translating items in the chart.
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
@@ -105,7 +103,7 @@ export default () => ({
|
||||
labels: [],
|
||||
datasets: [
|
||||
{
|
||||
label: i18n.t('firefly.spent'),
|
||||
label: i18next.t('firefly.spent'),
|
||||
data: [],
|
||||
borderWidth: 1,
|
||||
stack: 1,
|
||||
@@ -113,7 +111,7 @@ export default () => ({
|
||||
borderColor: getColors('spent', 'border'),
|
||||
},
|
||||
{
|
||||
label: i18n.t('firefly.left'),
|
||||
label: i18next.t('firefly.left'),
|
||||
data: [],
|
||||
borderWidth: 1,
|
||||
stack: 1,
|
||||
@@ -121,7 +119,7 @@ export default () => ({
|
||||
borderColor: getColors('left', 'border'),
|
||||
},
|
||||
{
|
||||
label: i18n.t('firefly.overspent'),
|
||||
label: i18next.t('firefly.overspent'),
|
||||
data: [],
|
||||
borderWidth: 1,
|
||||
stack: 1,
|
||||
@@ -174,19 +172,12 @@ export default () => ({
|
||||
|
||||
|
||||
init() {
|
||||
// console.log('budgets init');
|
||||
Promise.all([getVariable('autoConversion', false), getVariable('language', 'en_US')]).then((values) => {
|
||||
|
||||
i18n = new I18n();
|
||||
const locale = values[1].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
this.autoConversion = values[0];
|
||||
afterPromises = true;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
}
|
||||
});
|
||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
||||
this.autoConversion = values[0];
|
||||
afterPromises = true;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
}
|
||||
});
|
||||
window.store.observe('end', () => {
|
||||
if (!afterPromises) {
|
||||
|
||||
@@ -27,26 +27,27 @@ import categories from './categories.js';
|
||||
import sankey from './sankey.js';
|
||||
import subscriptions from './subscriptions.js';
|
||||
import piggies from './piggies.js';
|
||||
|
||||
|
||||
import {
|
||||
ArcElement,
|
||||
BarController,
|
||||
BarElement,
|
||||
CategoryScale,
|
||||
Chart,
|
||||
Colors,
|
||||
Filler,
|
||||
Legend,
|
||||
LinearScale,
|
||||
LineController,
|
||||
LineElement,
|
||||
PieController,
|
||||
BarController,
|
||||
BarElement,
|
||||
TimeScale,
|
||||
ArcElement,
|
||||
LinearScale,
|
||||
Legend,
|
||||
Filler,
|
||||
Colors,
|
||||
CategoryScale,
|
||||
PointElement,
|
||||
TimeScale,
|
||||
Tooltip
|
||||
} from "chart.js";
|
||||
import 'chartjs-adapter-date-fns';
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import i18next from "i18next";
|
||||
|
||||
// register things
|
||||
Chart.register({
|
||||
@@ -77,13 +78,20 @@ const comps = {
|
||||
piggies
|
||||
};
|
||||
|
||||
//let i18n;
|
||||
|
||||
function loadPage(comps) {
|
||||
Object.keys(comps).forEach(comp => {
|
||||
console.log(`Loading page component "${comp}"`);
|
||||
let data = comps[comp]();
|
||||
Alpine.data(comp, () => data);
|
||||
Promise.all([getVariable('language', 'en_US')]).then((values) => {
|
||||
loadTranslations(values[0]).then(() => {
|
||||
Object.keys(comps).forEach(comp => {
|
||||
let data = comps[comp]();
|
||||
Alpine.data(comp, () => data);
|
||||
});
|
||||
Alpine.start();
|
||||
});
|
||||
});
|
||||
Alpine.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// wait for load until bootstrapped event is received.
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
*/
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import Get from "../../api/v2/model/piggy-bank/get.js";
|
||||
import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {getCacheKey} from "../../support/get-cache-key.js";
|
||||
import {format} from "date-fns";
|
||||
import i18next from "i18next";
|
||||
|
||||
let apiData = {};
|
||||
let afterPromises = false;
|
||||
let i18n;
|
||||
const PIGGY_CACHE_KEY = 'dashboard-piggies-data';
|
||||
|
||||
export default () => ({
|
||||
@@ -84,7 +82,7 @@ export default () => ({
|
||||
if (0 === current.attributes.percentage) {
|
||||
continue;
|
||||
}
|
||||
let groupName = current.object_group_title ?? i18n.t('firefly.default_group_title_name_plain');
|
||||
let groupName = current.object_group_title ?? i18next.t('firefly.default_group_title_name_plain');
|
||||
if (!dataSet.hasOwnProperty(groupName)) {
|
||||
dataSet[groupName] = {
|
||||
id: current.object_group_id ?? 0,
|
||||
@@ -130,18 +128,11 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('piggies init');
|
||||
apiData = [];
|
||||
Promise.all([getVariable('autoConversion', false), getVariable('language', 'en_US')]).then((values) => {
|
||||
|
||||
i18n = new I18n();
|
||||
const locale = values[1].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
// console.log('piggies after promises');
|
||||
afterPromises = true;
|
||||
this.autoConversion = values[0];
|
||||
this.loadPiggyBanks();
|
||||
});
|
||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
||||
|
||||
afterPromises = true;
|
||||
this.autoConversion = values[0];
|
||||
this.loadPiggyBanks();
|
||||
|
||||
});
|
||||
window.store.observe('end', () => {
|
||||
|
||||
@@ -23,14 +23,13 @@ import {getDefaultChartSettings} from "../../support/default-chart-settings.js";
|
||||
import {Chart} from 'chart.js';
|
||||
import {Flow, SankeyController} from 'chartjs-chart-sankey';
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {I18n} from "i18n-js";
|
||||
import {getCacheKey} from "../../support/get-cache-key.js";
|
||||
import {format} from "date-fns";
|
||||
import i18next from "i18next";
|
||||
|
||||
Chart.register({SankeyController, Flow});
|
||||
|
||||
const SANKEY_CACHE_KEY = 'dashboard-sankey-data';
|
||||
let i18n;
|
||||
let currencies = [];
|
||||
let afterPromises = false;
|
||||
let chart = null;
|
||||
@@ -350,31 +349,26 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('sankey init');
|
||||
transactions = [];
|
||||
Promise.all([getVariable('autoConversion', false), getVariable('language', 'en_US')]).then((values) => {
|
||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
||||
this.autoConversion = values[0];
|
||||
autoConversion = values[0];
|
||||
i18n = new I18n();
|
||||
const locale = values[1].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
// some translations:
|
||||
translations.all_money = i18n.t('firefly.all_money');
|
||||
translations.category = i18n.t('firefly.category');
|
||||
translations.in = i18n.t('firefly.money_flowing_in');
|
||||
translations.out = i18n.t('firefly.money_flowing_out');
|
||||
translations.unknown_category = i18n.t('firefly.unknown_category_plain');
|
||||
translations.unknown_source = i18n.t('firefly.unknown_source_plain');
|
||||
translations.unknown_dest = i18n.t('firefly.unknown_dest_plain');
|
||||
translations.unknown_account = i18n.t('firefly.unknown_any_plain');
|
||||
translations.unknown_budget = i18n.t('firefly.unknown_budget_plain');
|
||||
translations.expense_account = i18n.t('firefly.expense_account');
|
||||
translations.revenue_account = i18n.t('firefly.revenue_account');
|
||||
translations.budget = i18n.t('firefly.budget');
|
||||
translations.all_money = i18next.t('firefly.all_money');
|
||||
translations.category = i18next.t('firefly.category');
|
||||
translations.in = i18next.t('firefly.money_flowing_in');
|
||||
translations.out = i18next.t('firefly.money_flowing_out');
|
||||
translations.unknown_category = i18next.t('firefly.unknown_category_plain');
|
||||
translations.unknown_source = i18next.t('firefly.unknown_source_plain');
|
||||
translations.unknown_dest = i18next.t('firefly.unknown_dest_plain');
|
||||
translations.unknown_account = i18next.t('firefly.unknown_any_plain');
|
||||
translations.unknown_budget = i18next.t('firefly.unknown_budget_plain');
|
||||
translations.expense_account = i18next.t('firefly.expense_account');
|
||||
translations.revenue_account = i18next.t('firefly.revenue_account');
|
||||
translations.budget = i18next.t('firefly.budget');
|
||||
|
||||
// console.log('sankey after promises');
|
||||
afterPromises = true;
|
||||
this.loadChart();
|
||||
});
|
||||
|
||||
});
|
||||
window.store.observe('end', () => {
|
||||
|
||||
@@ -20,17 +20,14 @@
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import Get from "../../api/v2/model/subscription/get.js";
|
||||
import {format} from "date-fns";
|
||||
import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {getCacheKey} from "../../support/get-cache-key.js";
|
||||
import {Chart} from "chart.js";
|
||||
import formatMoney from "../../util/format-money.js";
|
||||
|
||||
import i18next from "i18next";
|
||||
|
||||
// let chart = null;
|
||||
// let chartData = null;
|
||||
let afterPromises = false;
|
||||
let i18n; // for translating items in the chart.
|
||||
let apiData = [];
|
||||
let subscriptionData = {};
|
||||
|
||||
@@ -47,7 +44,7 @@ function downloadSubscriptions(params) {
|
||||
//console.log(current);
|
||||
if (current.attributes.active && current.attributes.pay_dates.length > 0) {
|
||||
let objectGroupId = null === current.attributes.object_group_id ? 0 : current.attributes.object_group_id;
|
||||
let objectGroupTitle = null === current.attributes.object_group_title ? i18n.t('firefly.default_group_title_name_plain') : current.attributes.object_group_title;
|
||||
let objectGroupTitle = null === current.attributes.object_group_title ? i18next.t('firefly.default_group_title_name_plain') : current.attributes.object_group_title;
|
||||
let objectGroupOrder = null === current.attributes.object_group_order ? 0 : current.attributes.object_group_order;
|
||||
if (!subscriptionData.hasOwnProperty(objectGroupId)) {
|
||||
subscriptionData[objectGroupId] = {
|
||||
@@ -84,7 +81,7 @@ function downloadSubscriptions(params) {
|
||||
// set variables
|
||||
bill.expected_amount = params.autoConversion ? formatMoney(bill.native_amount, bill.native_currency_code) :
|
||||
formatMoney(bill.amount, bill.currency_code);
|
||||
bill.expected_times = i18n.t('firefly.subscr_expected_x_times', {
|
||||
bill.expected_times = i18next.t('firefly.subscr_expected_x_times', {
|
||||
times: current.attributes.pay_dates.length,
|
||||
amount: bill.expected_amount
|
||||
});
|
||||
@@ -198,7 +195,6 @@ export default () => ({
|
||||
// reset subscription data
|
||||
subscriptionData = {};
|
||||
this.subscriptions = [];
|
||||
console.log('cache is invalid, must download');
|
||||
let params = {
|
||||
start: format(start, 'y-MM-dd'),
|
||||
end: format(end, 'y-MM-dd'),
|
||||
@@ -206,7 +202,6 @@ export default () => ({
|
||||
page: 1
|
||||
};
|
||||
downloadSubscriptions(params).then(() => {
|
||||
console.log('Done with download!');
|
||||
let set = Object.values(subscriptionData);
|
||||
// convert subscriptionData to usable data (especially for the charts)
|
||||
for (let i in set) {
|
||||
@@ -236,11 +231,11 @@ export default () => ({
|
||||
const currencyCode = this.autoConversion ? data.native_currency_code : data.currency_code;
|
||||
const chartData = {
|
||||
labels: [
|
||||
i18n.t('firefly.paid'),
|
||||
i18n.t('firefly.unpaid')
|
||||
i18next.t('firefly.paid'),
|
||||
i18next.t('firefly.unpaid')
|
||||
],
|
||||
datasets: [{
|
||||
label: i18n.t('firefly.subscriptions_in_group', {title: groupTitle}),
|
||||
label: i18next.t('firefly.subscriptions_in_group', {title: groupTitle}),
|
||||
data: [paidAmount, unpaidAmount],
|
||||
backgroundColor: [
|
||||
'rgb(54, 162, 235)',
|
||||
@@ -272,20 +267,13 @@ export default () => ({
|
||||
},
|
||||
|
||||
init() {
|
||||
console.log('subscriptions init');
|
||||
Promise.all([getVariable('autoConversion', false), getVariable('language', 'en_US')]).then((values) => {
|
||||
console.log('subscriptions after promises');
|
||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
||||
this.autoConversion = values[0];
|
||||
afterPromises = true;
|
||||
|
||||
i18n = new I18n();
|
||||
const locale = values[1].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
}
|
||||
});
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -293,7 +281,6 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
console.log('subscriptions observe end');
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
}
|
||||
@@ -302,7 +289,6 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
console.log('subscriptions observe autoConversion');
|
||||
this.autoConversion = newValue;
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
subMonths
|
||||
} from "date-fns";
|
||||
import format from '../../util/format'
|
||||
import i18next from "i18next";
|
||||
|
||||
export default () => ({
|
||||
range: {
|
||||
@@ -44,8 +45,7 @@ export default () => ({
|
||||
language: 'en_US',
|
||||
|
||||
init() {
|
||||
// console.log('Dates init');
|
||||
|
||||
console.log(`Loading page component "DATES" with language "${i18next.t('key')}".`);
|
||||
this.range = {
|
||||
start: new Date(window.store.get('start')),
|
||||
end: new Date(window.store.get('end'))
|
||||
@@ -67,23 +67,6 @@ export default () => ({
|
||||
this.range.end = new Date(newValue);
|
||||
this.buildDateRange();
|
||||
});
|
||||
|
||||
//this.range = this.setDatesFromViewRange(this.range.start);
|
||||
// get values from store and use them accordingly.
|
||||
// this.viewRange = window.BasicStore.get('viewRange');
|
||||
// this.locale = window.BasicStore.get('locale');
|
||||
// this.language = window.BasicStore.get('language');
|
||||
// this.locale = 'equal' === this.locale ? this.language : this.locale;
|
||||
// window.__localeId__ = this.language;
|
||||
//
|
||||
// // the range is always null but later on we will store it in BasicStore.
|
||||
// if (null === this.range.start && null === this.range.end) {
|
||||
// console.log('start + end = null, calling setDatesFromViewRange()');
|
||||
// this.range = this.setDatesFromViewRange(new Date);
|
||||
// }
|
||||
// console.log('MainApp: set defaultRange');
|
||||
// this.defaultRange = this.setDatesFromViewRange(new Date);
|
||||
// // default range is always the current period (initialized ahead)
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import {parseFromEntries} from "./shared/parse-from-entries.js";
|
||||
import formatMoney from "../../util/format-money.js";
|
||||
import Post from "../../api/v2/model/transaction/post.js";
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import {loadCurrencies} from "./shared/load-currencies.js";
|
||||
import {loadBudgets} from "./shared/load-budgets.js";
|
||||
@@ -46,14 +45,13 @@ import {processAttachments} from "./shared/process-attachments.js";
|
||||
import {spliceErrorsIntoTransactions} from "./shared/splice-errors-into-transactions.js";
|
||||
import Tags from "bootstrap5-tags";
|
||||
import {addLocation} from "./shared/manage-locations.js";
|
||||
import i18next from "i18next";
|
||||
// TODO upload attachments to other file
|
||||
// TODO fix two maps, perhaps disconnect from entries entirely.
|
||||
// TODO group title
|
||||
// TODO map location from preferences
|
||||
// TODO field preferences
|
||||
|
||||
let i18n;
|
||||
|
||||
const urls = getUrls();
|
||||
|
||||
let transactions = function () {
|
||||
@@ -272,21 +270,13 @@ let transactions = function () {
|
||||
this.notifications.wait.show = false;
|
||||
this.notifications.error.show = true;
|
||||
this.formStates.isSubmitting = false;
|
||||
this.notifications.error.text = i18n.t('firefly.errors_upload');
|
||||
this.notifications.error.text = i18next.t('firefly.errors_upload');
|
||||
console.error(event);
|
||||
},
|
||||
|
||||
init() {
|
||||
// get translations
|
||||
// TODO loading translations could be better, but do this later.
|
||||
Promise.all([getVariable('language', 'en_US')]).then((values) => {
|
||||
i18n = new I18n();
|
||||
const locale = values[0].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
this.addSplit();
|
||||
});
|
||||
});
|
||||
this.addSplit();
|
||||
|
||||
// load currencies and save in form data.
|
||||
loadCurrencies().then(data => {
|
||||
this.formStates.loadingCurrencies = false;
|
||||
@@ -389,7 +379,7 @@ let transactions = function () {
|
||||
if (attachmentCount > 0) {
|
||||
// if count is more than zero, system is processing transactions in the background.
|
||||
this.notifications.wait.show = true;
|
||||
this.notifications.wait.text = i18n.t('firefly.wait_attachments');
|
||||
this.notifications.wait.text = i18next.t('firefly.wait_attachments');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -418,7 +408,7 @@ let transactions = function () {
|
||||
|
||||
this.notifications.success.show = true;
|
||||
this.notifications.success.url = 'transactions/show/' + this.groupProperties.id;
|
||||
this.notifications.success.text = i18n.t('firefly.stored_journal_js', {description: this.groupProperties.title});
|
||||
this.notifications.success.text = i18next.t('firefly.stored_journal_js', {description: this.groupProperties.title});
|
||||
|
||||
if (this.formStates.resetButton) {
|
||||
this.entries = [];
|
||||
@@ -436,7 +426,7 @@ let transactions = function () {
|
||||
this.notifications.success.show = false;
|
||||
this.notifications.wait.show = false;
|
||||
this.formStates.isSubmitting = false;
|
||||
this.notifications.error.text = i18n.t('firefly.errors_submission', {errorMessage: data.message});
|
||||
this.notifications.error.text = i18next.t('firefly.errors_submission', {errorMessage: data.message});
|
||||
|
||||
if (data.hasOwnProperty('errors')) {
|
||||
this.entries = spliceErrorsIntoTransactions(i18n, data.errors, this.entries);
|
||||
@@ -454,7 +444,7 @@ let transactions = function () {
|
||||
liveServer: true,
|
||||
clearEnd: true,
|
||||
allowNew: true,
|
||||
notFoundMessage: i18n.t('firefly.nothing_found'),
|
||||
notFoundMessage: i18next.t('firefly.nothing_found'),
|
||||
noCache: true,
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
@@ -469,7 +459,7 @@ let transactions = function () {
|
||||
// addedSplit, is called from the HTML
|
||||
// for source account
|
||||
const renderAccount = function (item, b, c) {
|
||||
return item.name_with_balance + '<br><small class="text-muted">' + i18n.t('firefly.account_type_' + item.type) + '</small>';
|
||||
return item.name_with_balance + '<br><small class="text-muted">' + i18next.t('firefly.account_type_' + item.type) + '</small>';
|
||||
};
|
||||
addAutocomplete({
|
||||
selector: 'input.ac-source',
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
import '../../boot/bootstrap.js';
|
||||
import dates from '../../pages/shared/dates.js';
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import formatMoney from "../../util/format-money.js";
|
||||
import Get from "../../api/v2/model/transaction/get.js";
|
||||
@@ -40,6 +39,7 @@ import {loadBudgets} from "./shared/load-budgets.js";
|
||||
import {loadPiggyBanks} from "./shared/load-piggy-banks.js";
|
||||
import {loadSubscriptions} from "./shared/load-subscriptions.js";
|
||||
import Tags from "bootstrap5-tags";
|
||||
import i18next from "i18next";
|
||||
|
||||
// TODO upload attachments to other file
|
||||
// TODO fix two maps, perhaps disconnect from entries entirely.
|
||||
@@ -49,7 +49,6 @@ import Tags from "bootstrap5-tags";
|
||||
// TODO filters
|
||||
// TODO parse amount
|
||||
|
||||
let i18n;
|
||||
const urls = getUrls();
|
||||
|
||||
let transactions = function () {
|
||||
@@ -116,7 +115,7 @@ let transactions = function () {
|
||||
// addedSplit, is called from the HTML
|
||||
// for source account
|
||||
const renderAccount = function (item, b, c) {
|
||||
return item.name_with_balance + '<br><small class="text-muted">' + i18n.t('firefly.account_type_' + item.type) + '</small>';
|
||||
return item.name_with_balance + '<br><small class="text-muted">' + i18next.t('firefly.account_type_' + item.type) + '</small>';
|
||||
};
|
||||
addAutocomplete({
|
||||
selector: 'input.ac-source',
|
||||
@@ -218,7 +217,7 @@ let transactions = function () {
|
||||
liveServer: true,
|
||||
clearEnd: true,
|
||||
allowNew: true,
|
||||
notFoundMessage: i18n.t('firefly.nothing_found'),
|
||||
notFoundMessage: i18next.t('firefly.nothing_found'),
|
||||
noCache: true,
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
@@ -232,17 +231,9 @@ let transactions = function () {
|
||||
|
||||
init() {
|
||||
// download translations and get the transaction group.
|
||||
Promise.all([getVariable('language', 'en_US')]).then((values) => {
|
||||
i18n = new I18n();
|
||||
const locale = values[0].replace('-', '_');
|
||||
i18n.locale = locale;
|
||||
loadTranslations(i18n, locale).then(() => {
|
||||
//this.addSplit();
|
||||
this.notifications.wait.show = true;
|
||||
this.notifications.wait.text = i18n.t('firefly.wait_loading_transaction');
|
||||
this.getTransactionGroup();
|
||||
});
|
||||
});
|
||||
this.notifications.wait.show = true;
|
||||
this.notifications.wait.text = i18next.t('firefly.wait_loading_transaction');
|
||||
this.getTransactionGroup();
|
||||
|
||||
// load meta data.
|
||||
loadCurrencies().then(data => {
|
||||
|
||||
@@ -18,16 +18,49 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
let loaded = false;
|
||||
|
||||
async function loadTranslations(i18n, locale) {
|
||||
if (false === loaded) {
|
||||
locale = locale.replace('-', '_');
|
||||
const response = await fetch(`./v2/i18n/${locale}.json`);
|
||||
const translations = await response.json();
|
||||
i18n.store(translations);
|
||||
import i18next from "i18next";
|
||||
import ChainedBackend from "i18next-chained-backend";
|
||||
import HttpBackend from "i18next-http-backend";
|
||||
import LocalStorageBackend from "i18next-localstorage-backend";
|
||||
|
||||
|
||||
|
||||
|
||||
let loaded = false;
|
||||
let count = 0;
|
||||
|
||||
function loadTranslations(locale) {
|
||||
if (false === loaded && 0 === count) {
|
||||
console.log('Loading translations: ' + count);
|
||||
const replacedLocale = locale.replace('-', '_');
|
||||
loaded = true;
|
||||
count++;
|
||||
|
||||
return i18next
|
||||
.use(ChainedBackend)
|
||||
.init({
|
||||
fallbackLng: "en_US",
|
||||
lng: replacedLocale,
|
||||
debug: true,
|
||||
// ... your i18next config
|
||||
backend: {
|
||||
backends: [
|
||||
LocalStorageBackend,
|
||||
HttpBackend
|
||||
],
|
||||
backendOptions: [{
|
||||
expirationTime: 7 * 24 * 60 * 60 * 1000 // 7 days
|
||||
}, {
|
||||
// const response = await fetch(`./v2/i18n/${locale}.json`);
|
||||
loadPath: './v2/i18n/{{lng}}.json'
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
//loaded = true;
|
||||
count++;
|
||||
console.warn('Loading translations skipped because count is:' + count);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
export {loadTranslations};
|
||||
|
||||
Reference in New Issue
Block a user