Add server translation (#9847)

First proof of concept for server-side translation.

The goal was to translate one metadata item:

<img width="939" alt="Screenshot 2025-01-26 at 08 18 41"
src="https://github.com/user-attachments/assets/e42a3f7f-f5e3-4ee7-9be5-272a2adccb23"
/>
This commit is contained in:
Félix Malfait
2025-01-27 21:07:49 +01:00
committed by GitHub
parent 2a911b4305
commit 549c3faf71
35 changed files with 412 additions and 131 deletions

View File

@ -0,0 +1,10 @@
import { Global, Module } from '@nestjs/common';
import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';
@Global()
@Module({
providers: [I18nService],
exports: [I18nService],
})
export class I18nModule {}

View File

@ -0,0 +1,16 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { i18n } from '@lingui/core';
import { messages as enMessages } from 'src/engine/core-modules/i18n/locales/generated/en.js';
import { messages as frMessages } from 'src/engine/core-modules/i18n/locales/generated/fr.js';
@Injectable()
export class I18nService implements OnModuleInit {
async onModuleInit() {
i18n.load('fr', frMessages);
i18n.load('en', enMessages);
i18n.activate('en');
}
}

View File

@ -0,0 +1,41 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2025-01-25 21:24+0100\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Plural-Forms: \n"
#. js-lingui-explicit-id
#: src/modules/company/standard-objects/company.workspace-entity.ts:56
#~ msgid "Company"
#~ msgstr "Company"
#. js-lingui-explicit-id
#: src/modules/company/standard-objects/company.workspace-entity.ts:57
#~ msgid "Companies"
#~ msgstr "Companies"
#. js-lingui-explicit-id
#: src/modules/company/standard-objects/company.workspace-entity.ts:58
#~ msgid "A company"
#~ msgstr "A company"
#: src/modules/company/standard-objects/company.workspace-entity.ts:58
msgid "A company"
msgstr "A company"
#: src/modules/company/standard-objects/company.workspace-entity.ts:57
msgid "Companies"
msgstr "Companies"
#: src/modules/company/standard-objects/company.workspace-entity.ts:56
msgid "Company"
msgstr "Company"

View File

@ -0,0 +1,20 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2025-01-26 21:19+0100\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: fr\n"
#: src/modules/company/standard-objects/company.workspace-entity.ts:58
msgid "A company"
msgstr "Une entreprise"
#: src/modules/company/standard-objects/company.workspace-entity.ts:57
msgid "Companies"
msgstr "Entreprises"
#: src/modules/company/standard-objects/company.workspace-entity.ts:56
msgid "Company"
msgstr "Entreprise"

View File

@ -0,0 +1 @@
/*eslint-disable*/module.exports={messages:JSON.parse("{\"Company\":[\"Company\"],\"Companies\":[\"Companies\"],\"A company\":[\"A company\"],\"kZR6+h\":[\"A company\"],\"s2QZS6\":[\"Companies\"],\"7i8j3G\":[\"Company\"]}")};

View File

@ -0,0 +1 @@
/*eslint-disable*/module.exports={messages:JSON.parse("{\"Company\":[\"Entreprise\"],\"Companies\":[\"Entreprises\"],\"A company\":[\"Une entreprise\"],\"kZR6+h\":[\"Une entreprise\"],\"s2QZS6\":[\"Entreprises\"],\"7i8j3G\":[\"Entreprise\"]}")};