mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
WIP: Arabic localization.|
This commit is contained in:
@@ -27,8 +27,10 @@ export default class AccountsTypesController extends BaseController {
|
||||
* @return {Response}
|
||||
*/
|
||||
getAccountTypesList(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const accountTypes = this.accountsTypesService.getAccountsTypes();
|
||||
const accountTypes = this.accountsTypesService.getAccountsTypes(tenantId);
|
||||
|
||||
return res.status(200).send({
|
||||
account_types: this.transfromToResponse(accountTypes, ['label'], req),
|
||||
|
||||
@@ -11,12 +11,16 @@ import BaseFinancialReportController from '../BaseFinancialReportController';
|
||||
import CashFlowStatementService from 'services/FinancialStatements/CashFlow/CashFlowService';
|
||||
import { ICashFlowStatementDOO, ICashFlowStatement } from 'interfaces';
|
||||
import CashFlowTable from 'services/FinancialStatements/CashFlow/CashFlowTable';
|
||||
import HasTenancyService from 'services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export default class CashFlowController extends BaseFinancialReportController {
|
||||
@Inject()
|
||||
cashFlowService: CashFlowStatementService;
|
||||
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
@@ -69,8 +73,9 @@ export default class CashFlowController extends BaseFinancialReportController {
|
||||
* @param {ITransactionsByVendorsStatement} statement -
|
||||
*
|
||||
*/
|
||||
private transformToTableRows(cashFlowDOO: ICashFlowStatementDOO) {
|
||||
const cashFlowTable = new CashFlowTable(cashFlowDOO);
|
||||
private transformToTableRows(cashFlowDOO: ICashFlowStatementDOO, tenantId: number) {
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
const cashFlowTable = new CashFlowTable(cashFlowDOO, i18n);
|
||||
|
||||
return {
|
||||
table: {
|
||||
@@ -103,7 +108,7 @@ export default class CashFlowController extends BaseFinancialReportController {
|
||||
|
||||
switch (acceptType) {
|
||||
case 'application/json+table':
|
||||
return res.status(200).send(this.transformToTableRows(cashFlow));
|
||||
return res.status(200).send(this.transformToTableRows(cashFlow, tenantId));
|
||||
case 'json':
|
||||
default:
|
||||
return res.status(200).send(this.transformJsonResponse(cashFlow));
|
||||
|
||||
@@ -10,12 +10,16 @@ import {
|
||||
import BaseController from 'api/controllers/BaseController';
|
||||
import InventoryDetailsService from 'services/FinancialStatements/InventoryDetails/InventoryDetailsService';
|
||||
import InventoryDetailsTable from 'services/FinancialStatements/InventoryDetails/InventoryDetailsTable';
|
||||
import HasTenancyService from 'services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export default class InventoryDetailsController extends BaseController {
|
||||
@Inject()
|
||||
inventoryDetailsService: InventoryDetailsService;
|
||||
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
@@ -71,8 +75,9 @@ export default class InventoryDetailsController extends BaseController {
|
||||
/**
|
||||
* Transformes the report statement to table rows.
|
||||
*/
|
||||
private transformToTableRows(inventoryDetails) {
|
||||
const inventoryDetailsTable = new InventoryDetailsTable(inventoryDetails);
|
||||
private transformToTableRows(inventoryDetails, tenantId: number) {
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
const inventoryDetailsTable = new InventoryDetailsTable(inventoryDetails, i18n);
|
||||
|
||||
return {
|
||||
table: {
|
||||
@@ -108,7 +113,7 @@ export default class InventoryDetailsController extends BaseController {
|
||||
case 'application/json+table':
|
||||
return res
|
||||
.status(200)
|
||||
.send(this.transformToTableRows(inventoryDetails));
|
||||
.send(this.transformToTableRows(inventoryDetails, tenantId));
|
||||
case 'json':
|
||||
default:
|
||||
return res
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
import { Container } from 'typedi';
|
||||
import i18n from 'i18n';
|
||||
|
||||
// Middlewares
|
||||
import JWTAuth from 'api/middleware/jwtAuth';
|
||||
@@ -47,6 +48,7 @@ export default () => {
|
||||
|
||||
// - Global routes.
|
||||
// ---------------------------
|
||||
app.use(i18n.init);
|
||||
app.use(I18nMiddleware);
|
||||
|
||||
app.use('/auth', Container.get(Authentication).router());
|
||||
|
||||
@@ -11,5 +11,6 @@ export default (req: Request, res: Response, next: NextFunction) => {
|
||||
}
|
||||
Logger.info('[i18n_middleware] set locale language to i18n.', { language, user: req.user });
|
||||
i18n.setLocale(req, language);
|
||||
|
||||
next();
|
||||
};
|
||||
@@ -6,6 +6,7 @@ import TenantsManagerService from 'services/Tenancy/TenantsManager';
|
||||
|
||||
export default (req: Request, tenant: ITenant) => {
|
||||
const { id: tenantId, organizationId } = tenant;
|
||||
|
||||
const tenantServices = Container.get(TenancyService);
|
||||
const tenantsManager = Container.get(TenantsManagerService);
|
||||
|
||||
@@ -17,7 +18,9 @@ export default (req: Request, tenant: ITenant) => {
|
||||
const repositories = tenantServices.repositories(tenantId)
|
||||
const cacheInstance = tenantServices.cache(tenantId);
|
||||
|
||||
tenantServices.setI18nLocals(tenantId, { __: req.__ });
|
||||
const tenantContainer = tenantServices.tenantContainer(tenantId);
|
||||
|
||||
tenantContainer.set('i18n', { __: req.__ });
|
||||
|
||||
req.knex = knexInstance;
|
||||
req.organizationId = organizationId;
|
||||
|
||||
Reference in New Issue
Block a user