WIP: Arabic localization.

This commit is contained in:
a.bouhuolia
2021-06-13 13:53:17 +02:00
parent 7d5bb95e75
commit 26bea3d2c2
27 changed files with 304 additions and 100 deletions

View File

@@ -8,6 +8,7 @@ import { IAccountDTO, IAccountsFilter } from 'interfaces';
import { ServiceError } from 'exceptions';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
import { DATATYPES_LENGTH } from 'data/DataTypes';
import I18nService from 'services/I18n/I18nService';
@Service()
export default class AccountsController extends BaseController {
@@ -17,6 +18,9 @@ export default class AccountsController extends BaseController {
@Inject()
dynamicListService: DynamicListingService;
@Inject()
i18nService: I18nService;
/**
* Router constructor method.
*/

View File

@@ -33,7 +33,6 @@ export default class BalanceSheetStatementController extends BaseFinancialReport
get balanceSheetValidationSchema(): ValidationChain[] {
return [
...this.sheetNumberFormatValidationSchema,
query('accounting_method').optional().isIn(['cash', 'accural']),
query('from_date').optional(),
query('to_date').optional(),

View File

@@ -11,9 +11,9 @@
"Inventory Asset": "المخزون",
"Cost of Goods Sold (COGS)": "تكلفة البضائع المباعة (COGS)",
"Cost of Goods Sold": "تكلفة البضاعة المباعة",
"Accounts Payable": "حسابات قابلة للدفع",
"Other Expense": "نفقات أخرى",
"Payroll Expenses": "نفقات الأجور",
"Accounts Payable": "الذمم الدائنة",
"Other Expense": "مصاريف أخرى",
"Payroll Expenses": "مصاريف المرتبات",
"Fixed Asset": "أصول ثابتة",
"Credit Card": "بطاقة إئتمان",
"Non-Current Asset": "أصول غير متداولة",
@@ -25,14 +25,14 @@
"Equity": "حقوق الملكية",
"Expense": "مصروف",
"Income": "دخل",
"Accounts Receivable (A/R)": "حسابات القبض (A / R)",
"Accounts Receivable (A/R)": "الذمم المدينة",
"Accounts Receivable": "الذمم المدينة",
"Accounts Payable (A/P)": "الحسابات الدائنة (A / P)",
"Accounts Payable (A/P)": "الذمم الدائنة",
"Inactive": "غير نشط",
"Other Current Asset": "اثار حالية اخري",
"Other Current Asset": "أصول متداولة اخرى",
"Tax Payable": "الضريبة المستحقة",
"Other Current Liability": "مطلوبات متداولة أخرى",
"Non-Current Liability": "المسؤولية غير المتداولة",
"Other Current Liability": "التزامات قصيرة الأجر اخرى",
"Non-Current Liability": "التزامات طويلة الأجر",
"Assets": "أصول",
"Liabilities": "الالتزمات",
"Account name": "أسم الحساب",
@@ -45,15 +45,15 @@
"Active": "نشيط",
"Created at": "أنشئت في",
"fixed_asset": "أصل ثابت",
"Journal": "مجلة",
"Reconciliation": صالح",
"Credit": "تنسب إليه",
"Debit": "دين",
"Journal": "قيد",
"Reconciliation": سوية",
"Credit": "دائن",
"Debit": "مدين",
"Interest": "فائدة",
"Depreciation": "الاستهلاك",
"Depreciation": "اهلاك",
"Payroll": "كشف رواتب",
"Type": "نوع",
"Name": "اسم",
"Name": "الأسم",
"Sellable": "قابل للبيع",
"Purchasable": "قابل للشراء",
"Sell price": "سعر البيع",
@@ -62,34 +62,33 @@
"Category": "تصنيف",
"Note": "ملحوظة",
"Quantity on hand": "كمية في اليد",
"Quantity": "الكمية",
"Purchase description": "وصف الشراء",
"Sell description": "وصف البيع",
"Sell account": "بيع حساب",
"Sell account": "حساب البيع",
"Cost account": "حساب التكلفة",
"Inventory account": "حساب الجرد",
"Inventory account": "حساب المخزون",
"Payment date": "تاريخ الدفع",
"Payment account": "حساب الدفع",
"Amount": "كمية",
"Reference No.": "رقم المرجع.",
"Published": "نشرت",
"Journal number": "رقم المجلة",
"Journal number": "رقم القيد",
"Status": "حالة",
"Journal type": "نوع المجلة",
"Journal type": "نوع القيد",
"Date": "تاريخ",
"Asset": "أصل",
"Liability": "مسؤلية",
"First-in first-out (FIFO)": "الوارد أولاً يصرف أولاً (FIFO)",
"Last-in first-out (LIFO)": "الوارد أخيرًا يصرف أولاً (LIFO)",
"Average rate": "المعدل المتوسط",
"Total": "مجموع",
"Total": "الإجمالي",
"Transaction type": "نوع المعاملة",
"Transaction #": "عملية #",
"Running Value": "القيمة الجارية",
"Running quantity": "الكمية الجارية",
"Profit Margin": "هامش الربح",
"Value": "قيمة",
"Rate": "معدل",
"Value": "القيمة",
"Rate": "السعر",
"OPERATING ACTIVITIES": "أنشطة التشغيل",
"FINANCIAL ACTIVITIES": "الأنشطة المالية",
"Net income": "صافي الدخل",
@@ -100,10 +99,10 @@
"Cash at beginning of period": "النقدية في بداية الفترة",
"NET CASH INCREASE FOR PERIOD": "زيادة صافي النقد للفترة",
"CASH AT END OF PERIOD": "النقد في نهاية الفترة",
"Expenses": "نفقات",
"Expenses": "مصاريف",
"Services": "خدمات",
"Inventory": "المخزون",
"Non-Inventory": "غير الجرد",
"Non-Inventory": "غير متعلق بالمخزون",
"Draft": "مسودة",
"Delivered": "تم التوصيل",
"Overdue": "متأخر",
@@ -116,13 +115,47 @@
"Invoiced": "مفوترة",
"Expired": "منتهي الصلاحية",
"Closed": "مغلق",
"Manual journal": "مجلة يدوية",
"Inventory adjustment": "ضبط المخزون",
"Customer opening balance": "الرصيد الافتتاحي للعميل",
"Vendor opening balance": "رصيد افتتاح البائع",
"Payment made": "تم الدفع",
"Bill": "مشروع قانون",
"Manual journal": "قيد اليدوي",
"Inventory adjustment": "تسوية المخزون",
"Customer opening balance": "الرصيد الافتتاحي للزبون",
"Vendor opening balance": "رصيد افتتاحي للمورد",
"Payment made": "سند الزبون",
"Bill": "فاتورة الشراء",
"Payment receive": "استلام الدفع",
"Sale receipt": "إيصال البيع",
"Sale invoice": "فاتورة البيع"
"Sale invoice": "فاتورة البيع",
"Quantity": "الكمية",
"Bank Account": "حساب البنك",
"Saving Bank Account": "حساب التوفير البنكي",
"Undeposited Funds": "الأموال غير المودعة",
"Computer Equipment": "معدات كمبيوتر",
"Office Equipment": "معدات مكتبية",
"Uncategorized Income": "الدخل غير مصنف",
"Sales of Service Income": "دخل مبيعات الخدمات",
"Bank Fees and Charges": "رسوم المصرفية",
"Exchange Gain or Loss": "ربح أو خسارة فروقات الصرف",
"Rent": "إيجار",
"Office expenses": "مصاريف المكتب",
"Other Expenses": "مصاريف اخري",
"Drawings": "السحوبات",
"Owner's Equity": "حقوق الملكية",
"Opening Balance Equity": "الارصدة الافتتاحية ",
"Retained Earnings": "الأرباح المحتجزة",
"Sales Tax Payable": "ضريبة المبيعات المستحقة",
"Revenue Received in Advance": "الإيرادات المقبوضة مقدما",
"Opening Balance Liabilities": "رصيد الالتزامات الافتتاحي",
"Loan": "اقراض",
"Owner A Drawings": "مسحوبات المالك",
"An account that holds valuation of products or goods that availiable for sale.": "حساب يحمل قيم مخزون البضاعة أو السلع المتاحة للبيع.",
"Tracks the gain and losses of the exchange differences.": "يسجل مكاسب وخسائر فروق الصرف.",
"Any bank fees levied is recorded into the bank fees and charges account. A bank account maintenance fee, transaction charges, a late payment fee are some examples.": "يتم تسجيل أي رسوم مصرفية يتم فرضها في حساب الرسوم والمصروفات البنكية. ومن الأمثلة على ذلك رسوم صيانة الحساب المصرفي ورسوم المعاملات ورسوم الدفع المتأخر.",
"The income activities are not associated to the core business.": "لا ترتبط انشطة الدخل إلى الأعمال الأساسية.",
"Cash and cash equivalents": "النقد والنقد المكافئ",
"Inventories": "مخزون البضاعة",
"Other current assets": "الأصول متداولة الأخرى",
"Non-Current Assets": "أصول غير المتداولة",
"Current Liabilties": "التزامات متداولة",
"Long-Term Liabilities": "التزامات طويلة الاجل",
"Non-Current Liabilities": "التزامات غير متداولة",
"Liabilities and Equity": "التزامات وحقوق الملكية"
}

View File

@@ -149,5 +149,13 @@
"An account that holds valuation of products or goods that availiable for sale.": "An account that holds valuation of products or goods that availiable for sale.",
"Tracks the gain and losses of the exchange differences.": "Tracks the gain and losses of the exchange differences.",
"Any bank fees levied is recorded into the bank fees and charges account. A bank account maintenance fee, transaction charges, a late payment fee are some examples.": "Any bank fees levied is recorded into the bank fees and charges account. A bank account maintenance fee, transaction charges, a late payment fee are some examples.",
"The income activities are not associated to the core business.": "The income activities are not associated to the core business."
"The income activities are not associated to the core business.": "The income activities are not associated to the core business.",
"Cash and cash equivalents": "Cash and cash equivalents",
"Inventories": "Inventories",
"Other current assets": "Other current assets",
"Non-Current Assets": "Non-Current Assets",
"Current Liabilties": "Current Liabilties",
"Long-Term Liabilities": "Long-Term Liabilities",
"Non-Current Liabilities": "Non-Current Liabilities",
"Liabilities and Equity": "Liabilities and Equity"
}

View File

@@ -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',
});

View File

@@ -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);
}
}

View File

@@ -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'

View File

@@ -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();

View File

@@ -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,
};
});
}