mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
WIP: Arabic localization.|
This commit is contained in:
29
server/src/services/I18n/I18nService.ts
Normal file
29
server/src/services/I18n/I18nService.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import HasTenancyService from 'services/Tenancy/TenancyService';
|
||||
import { Service, Inject } from 'typedi';
|
||||
|
||||
@Service()
|
||||
export default class I18nService {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Mappes array collection to i18n localization based in given attributes.
|
||||
* @param {Array<any>} data - Array collection.
|
||||
* @param {string[]} attributes - Attributes.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
*/
|
||||
public i18nMapper(
|
||||
data: Array<any>,
|
||||
attributes: string[] = [],
|
||||
tenantId: number
|
||||
) {
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
|
||||
return data.map((_data) => {
|
||||
return {
|
||||
label: i18n.__(_data.label),
|
||||
..._data,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user