mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
WIP: Arabic localization.
This commit is contained in:
@@ -21,6 +21,7 @@ import events from 'subscribers/events';
|
||||
import AccountTypesUtils from 'lib/AccountTypes';
|
||||
import { ERRORS } from './constants';
|
||||
import { flatToNestedArray } from 'utils';
|
||||
import I18nService from 'services/I18n/I18nService';
|
||||
|
||||
@Service()
|
||||
export default class AccountsService {
|
||||
@@ -36,6 +37,9 @@ export default class AccountsService {
|
||||
@EventDispatcher()
|
||||
eventDispatcher: EventDispatcherInterface;
|
||||
|
||||
@Inject()
|
||||
i18nService: I18nService;
|
||||
|
||||
/**
|
||||
* Retrieve account type or throws service error.
|
||||
* @param {number} tenantId -
|
||||
@@ -721,7 +725,9 @@ export default class AccountsService {
|
||||
...account.toJSON(),
|
||||
currencyCode: baseCurrency,
|
||||
}));
|
||||
return flatToNestedArray(_accounts, {
|
||||
return flatToNestedArray(
|
||||
this.i18nService.i18nMapper(_accounts, ['account_type_label'], tenantId),
|
||||
{
|
||||
id: 'id',
|
||||
parentId: 'parent_account_id',
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@ export default class AccountsTypesService implements IAccountsTypesService {
|
||||
*/
|
||||
public getAccountsTypes(tenantId: number): IAccountType[] {
|
||||
const accountTypes = AccountTypesUtils.getList();
|
||||
|
||||
return this.i18nService.i18nMapper(accountTypes, ['name'], tenantId);
|
||||
return this.i18nService.i18nMapper(accountTypes, ['label'], tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
||||
query: IBalanceSheetQuery,
|
||||
accounts: IAccount & { type: IAccountType }[],
|
||||
journalFinancial: IJournalPoster,
|
||||
baseCurrency: string
|
||||
baseCurrency: string,
|
||||
i18n
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -49,6 +50,8 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
||||
this.comparatorDateType =
|
||||
query.displayColumnsType === 'total' ? 'day' : query.displayColumnsBy;
|
||||
|
||||
this.i18n = i18n;
|
||||
|
||||
this.initDateRangeCollection();
|
||||
}
|
||||
|
||||
@@ -255,7 +258,7 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
||||
accounts: IAccount & { type: IAccountType }[]
|
||||
): IBalanceSheetSection {
|
||||
const result = {
|
||||
name: structure.name,
|
||||
name: this.i18n.__(structure.name),
|
||||
sectionType: structure.sectionType,
|
||||
type: structure.type,
|
||||
...(structure.type === 'accounts_section'
|
||||
|
||||
@@ -92,6 +92,8 @@ export default class BalanceSheetStatementService
|
||||
transactionsRepository,
|
||||
} = this.tenancy.repositories(tenantId);
|
||||
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
|
||||
// Settings tenant service.
|
||||
const settings = this.tenancy.settings(tenantId);
|
||||
const baseCurrency = settings.get({
|
||||
@@ -127,7 +129,8 @@ export default class BalanceSheetStatementService
|
||||
filter,
|
||||
accounts,
|
||||
transactionsJournal,
|
||||
baseCurrency
|
||||
baseCurrency,
|
||||
i18n
|
||||
);
|
||||
// Balance sheet data.
|
||||
const balanceSheetData = balanceSheetInstanace.reportData();
|
||||
|
||||
@@ -6,6 +6,22 @@ export default class I18nService {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i18n
|
||||
* @param attributes
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
private i18nAttributesMapper(i18n, attributes, data) {
|
||||
return attributes.reduce((acc, attr, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[attr]: i18n.__(acc[attr]),
|
||||
};
|
||||
}, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mappes array collection to i18n localization based in given attributes.
|
||||
* @param {Array<any>} data - Array collection.
|
||||
@@ -20,9 +36,11 @@ export default class I18nService {
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
|
||||
return data.map((_data) => {
|
||||
const newData = this.i18nAttributesMapper(i18n, attributes, _data);
|
||||
|
||||
return {
|
||||
label: i18n.__(_data.label),
|
||||
..._data,
|
||||
...newData,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user