Skip to content

Commit

Permalink
Merge pull request #402 from ZIMkaRU/feature/add-logic-to-have-separa…
Browse files Browse the repository at this point in the history
…ted-trans-by-langs

Add logic to have separated translations by language
  • Loading branch information
ezewer authored Sep 23, 2024
2 parents cb55be8 + 79f5af0 commit fa668c0
Show file tree
Hide file tree
Showing 28 changed files with 463 additions and 325 deletions.
15 changes: 15 additions & 0 deletions locales/en/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "Your report is ready",
"btnText": "Download Report",
"fileName": "File name",
"unauth": "Your file could not be completed, please try again",
"readyForDownload": "The report you request is ready for download",
"ifDidNotInitAction": "If you did not initiate this action and you suspect that your account may be compromised, please",
"freezeAccount": "freeze your account",
"contactSupport": "and contact support",
"youCan": "You can",
"download": "download",
"pgpSignature": "a PGP digital signature file"
}
}
16 changes: 16 additions & 0 deletions locales/en/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "Report",
"statementDetails": "Statement Details",
"statementDate": "Statement date",
"snapshotAt": "Snapshot at",
"period": "Period",
"username": "Username",
"email": "Email",
"errorMessage": "Your file could not be completed, please try again",
"reportGenAt": "Report generated at",
"copyright": "Copyright © 2013-2024 iFinex Inc. All rights reserved.",
"page": "Page",
"from": "from"
}
}
15 changes: 15 additions & 0 deletions locales/es-EM/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "Tu reporte esta listo",
"btnText": "Descargar el Informe",
"fileName": "Nombre del archivo",
"unauth": "Tu archivo no se pudo completar, intente de nuevo por favor.",
"readyForDownload": "Tu reporte esta listo para ser descargado",
"ifDidNotInitAction": "Si no realizaste esta acción y sospechas que tu cuenta puede estar comprometida, por favor",
"freezeAccount": "congela tu cuenta",
"contactSupport": "y contacta soporte",
"youCan": "Puedes",
"download": "descargar",
"pgpSignature": "un archivo con firma digital PGP"
}
}
16 changes: 16 additions & 0 deletions locales/es-EM/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "Reporte",
"statementDetails": "Detalles del Estado",
"statementDate": "Fecha del Estado",
"snapshotAt": "Captura al",
"period": "Periodo",
"username": "Nombre de Usuario",
"email": "Correo",
"errorMessage": "Tu archivo no pudo ser completado, por favor inténtalo de nuevo",
"reportGenAt": "Reporte generado al",
"copyright": "Copyright © 2013-2024 iFinex Inc. Todos los derechos reservados.",
"page": "Página",
"from": "de"
}
}
15 changes: 15 additions & 0 deletions locales/pt-BR/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "Seu relatório está pronto",
"btnText": "Baixar Relatório",
"fileName": "Nome do arquivo",
"unauth": "Não foi possível concluir seu arquivo, tente novamente",
"readyForDownload": "O relatório solicitado está pronto para download",
"ifDidNotInitAction": "Se você não iniciou esta ação e suspeita que sua conta pode estar comprometida",
"freezeAccount": "por favor, congele sua conta",
"contactSupport": "e entre em contato com o suporte",
"youCan": "Você pode",
"download": "baixar",
"pgpSignature": "um arquivo de assinatura digital PGP"
}
}
16 changes: 16 additions & 0 deletions locales/pt-BR/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "Informes",
"statementDetails": "Detalhes da declaração",
"statementDate": "Data da declaração",
"snapshotAt": "Captura de",
"period": "Período",
"username": "Nome de Usuário",
"email": "e-mail",
"errorMessage": "Seu arquivo não pode ser completado, por favor tente novamente",
"reportGenAt": "Informe gerado em ",
"copyright": "Copyright © 2013-2024 iFinex Inc. Todos os direitos reservados.",
"page": "Página",
"from": "de"
}
}
15 changes: 15 additions & 0 deletions locales/ru/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "Ваш отчет готов",
"btnText": "Скачать Отчет",
"fileName": "Имя файла",
"unauth": "Ваш файл не может быть завершен, пожалуйста, попробуйте еще раз",
"readyForDownload": "Запрашиваемый вами отчет готов к загрузке",
"ifDidNotInitAction": "Если вы не инициировали это действие и подозреваете, что ваша учетная запись может быть взломана, пожалуйста,",
"freezeAccount": "заблокируйте ее",
"contactSupport": "и обратитесь в службу поддержки",
"youCan": "Вы можете",
"download": "скачать",
"pgpSignature": "файл цифровой подписи PGP"
}
}
16 changes: 16 additions & 0 deletions locales/ru/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "Отчет",
"statementDetails": "Детали ведомости",
"statementDate": "Дата ведомости",
"snapshotAt": "Снимок в",
"period": "Период",
"username": "Имя пользователя",
"email": "Эл. почта",
"errorMessage": "Ваш файл не может быть завершен, пожалуйста, попробуйте еще раз",
"reportGenAt": "Отчет сгенерирован в",
"copyright": "Авторское право © 2013-2024 iFinex Inc. Все права защищены.",
"page": "Стр.",
"from": "из"
}
}
15 changes: 15 additions & 0 deletions locales/tr/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "Raporunuz hazır",
"btnText": "Raporu İndir",
"fileName": "Dosya adı",
"unauth": "Dosyanız tamamlanamadı, lütfen tekrar deneyin",
"readyForDownload": "İstediğiniz rapor indirilmeye hazır",
"ifDidNotInitAction": "Bu işlemi siz başlatmadıysanız ve hesabınızın güvenliğinin ihlal edilmiş olabileceğinden şüpheleniyorsanız, lütfen",
"freezeAccount": "hesabınızı dondurun",
"contactSupport": "ve destek ekibiyle iletişime geçin",
"youCan": "Yapabilirsiniz",
"download": "indir",
"pgpSignature": "bir PGP dijital imza dosyası"
}
}
16 changes: 16 additions & 0 deletions locales/tr/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "Rapor",
"statementDetails": "Beyanname Detayları",
"statementDate": "Beyanname Tarihi",
"snapshotAt": "Anlık Görüntü:",
"period": "Dönem",
"username": "Kullanıcı Adı",
"email": "Email",
"errorMessage": "Dosyanız tamamlanamadı, lütfen tekrar deneyin",
"reportGenAt": "Rapor şu tarihte oluşturuldu:",
"copyright": "Telif Hakkı © 2013-2024 iFinex Inc. Tüm hakları saklıdır.",
"page": "Sayfa",
"from": "İtibaren"
}
}
15 changes: 15 additions & 0 deletions locales/zh-CN/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "您的报告已备妥",
"btnText": "下载报告档案",
"fileName": "档案名称",
"unauth": "档案未下载成功,请重试一次",
"readyForDownload": "您请求的报告已可下载",
"ifDidNotInitAction": "如果您未进行此操作并且怀疑您的帐户已遭盗用,请",
"freezeAccount": "冻结您的帐户",
"contactSupport": "以及联络客服人员",
"youCan": "您可以",
"download": "下载",
"pgpSignature": "PGP数位签名档"
}
}
16 changes: 16 additions & 0 deletions locales/zh-CN/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "报告",
"statementDetails": "结算明细",
"statementDate": "结算日期",
"snapshotAt": "快照时间",
"period": "期间",
"username": "用户名",
"email": "电子邮箱",
"errorMessage": "无法建立档案,请重试",
"reportGenAt": "报告创建时间",
"copyright": "Copyright © 2013-2024 iFinex Inc. All rights reserved.",
"page": "页数",
"from": ""
}
}
15 changes: 15 additions & 0 deletions locales/zh-TW/email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"template": {
"subject": "您的報告已備妥",
"btnText": "下載报告檔案",
"fileName": "檔案名稱",
"unauth": "檔案未下載成功,請重試一次",
"readyForDownload": "您請求的報告已可下載",
"ifDidNotInitAction": "如果您未進行此操作並且懷疑您的帳戶已遭盜用,請",
"freezeAccount": "凍結您的帳戶",
"contactSupport": "以及聯絡客服人員",
"youCan": "您可以",
"download": "下載",
"pgpSignature": "PGP數位簽名檔案"
}
}
16 changes: 16 additions & 0 deletions locales/zh-TW/pdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"template": {
"title": "報告",
"statementDetails": "結算明細",
"statementDate": "結算日期",
"snapshotAt": "快照時間:",
"period": "期間",
"username": "用戶名",
"email": "電子郵箱",
"errorMessage": "無法建立檔案,請重試",
"reportGenAt": "報告建立時間:",
"copyright": "Copyright © 2013-2024 iFinex Inc. All rights reserved.",
"page": "頁數",
"from": ""
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"bitfinex-api-node": "6.0.0",
"colors": "1.4.0",
"csv": "5.5.3",
"i18next": "23.15.1",
"i18next-fs-backend": "2.3.2",
"inversify": "6.0.1",
"js-yaml": "4.1.0",
"lib-js-util-base": "git+https://github.com/bitfinexcom/lib-js-util-base.git",
"lru": "3.1.0",
"moment": "2.29.4",
Expand Down
20 changes: 20 additions & 0 deletions workers/api.service.report.wrk.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TYPES = require('./loc.api/di/types')
const {
setLoggerDeps
} = require('./loc.api/logger/logger-deps')
const getI18next = require('./loc.api/i18next')
const {
PDFBufferUnderElectronCreationError
} = require('./loc.api/errors')
Expand All @@ -60,6 +61,7 @@ class WrkReportServiceApi extends WrkApi {

this.coreDeps = []
this.appDeps = []
this.transPaths = []

this.loadDIConfig()
this.loadCoreDeps()
Expand All @@ -70,6 +72,11 @@ class WrkReportServiceApi extends WrkApi {
this.start()
}

addTransLocation (transPath) {
const _transPath = transPath ?? path.join(__dirname, '../locales')
this.transPaths.push(_transPath)
}

loadDIConfig (cont = container) {
const conf = this.conf[this.group]

Expand All @@ -88,6 +95,15 @@ class WrkReportServiceApi extends WrkApi {
this.container.load(...this.appDeps)
}

async getI18next (i18nextConfigs) {
const i18next = await getI18next({
i18nextConfigs,
transPaths: this.transPaths
})

return i18next
}

getPluginCtx (type) {
const ctx = super.getPluginCtx(type)

Expand Down Expand Up @@ -124,6 +140,7 @@ class WrkReportServiceApi extends WrkApi {

init () {
super.init()
this.addTransLocation()

const dbPathAbsolute = path.isAbsolute(argv.dbFolder)
? argv.dbFolder
Expand Down Expand Up @@ -179,13 +196,16 @@ class WrkReportServiceApi extends WrkApi {
rService.ctx = rService.caller.getCtx()
}

const i18next = await this.getI18next()

this.loadAppDeps({
rService,
processorQueue,
aggregatorQueue,
link: this.grc_bfx.link,
deflateFac: this.deflate_gzip,
grcSlackFac,
i18next,
...deps
})

Expand Down
12 changes: 9 additions & 3 deletions workers/loc.api/di/app.deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ module.exports = ({
aggregatorQueue,
deflateFac,
grcSlackFac,
link
link,
i18next
}) => {
return new ContainerModule((bind) => {
bind(TYPES.RService).toConstantValue(rService)
bind(TYPES.RootPath).toConstantValue(rService.ctx.rootPath)
bind(TYPES.I18next).toConstantValue(i18next)
bind(TYPES.RServiceDepsSchema).toConstantValue([
['_responder', TYPES.Responder],
['_getREST', TYPES.GetREST],
['_grcBfxReq', TYPES.GrcBfxReq],
['_prepareApiResponse', TYPES.PrepareApiResponse],
['_generateReportFile', TYPES.GenerateReportFile],
['_hasGrcService', TYPES.HasGrcService],
['_weightedAveragesReport', TYPES.WeightedAveragesReport]
['_weightedAveragesReport', TYPES.WeightedAveragesReport],
['_i18next', TYPES.I18next]
])
bind(TYPES.RServiceDepsSchemaAliase)
.toDynamicValue((ctx) => {
Expand Down Expand Up @@ -164,7 +167,10 @@ module.exports = ({
bind(TYPES.SendMail).toConstantValue(
bindDepsToFn(
sendMail,
[TYPES.GrcBfxReq]
[
TYPES.GrcBfxReq,
TYPES.I18next
]
)
)
bind(TYPES.Processor)
Expand Down
1 change: 1 addition & 0 deletions workers/loc.api/di/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
Container: Symbol.for('Container'),
LoggerFactory: Symbol.for('LoggerFactory'),
Logger: Symbol.for('Logger'),
I18next: Symbol.for('I18next'),
RService: Symbol.for('RService'),
DeflateFac: Symbol.for('DeflateFac'),
GrcSlackFac: Symbol.for('GrcSlackFac'),
Expand Down
Loading

0 comments on commit fa668c0

Please sign in to comment.