flowable / flowable/flowable-engine

Can the framework output information support multiple languages

Offen
#3,097 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
9.5k
Forks
2.9k
Ø Merge
7 Std. 8 Min.
Gemergte PRs (30 T.)
2

Beschreibung

Recently, the project is internationalizing user operation logs. Why do user operations need logs? When working as a cloud platform, you need to record the user's behavior of operating resources. For example, when creating a host, you need to record it and show it to users in the log module. Such a log module can help users check whether the operation is successful and view the operation history, You can also query the latest operation records by time. Now there is a demand that this cloud platform needs to be used not only for Chinese users, but also for foreign users. The display language used by the system needs to be dynamically switched. You need to dynamically switch between Chinese and English according to the needs of users. We focus on the log. The log needs to record the user's operation name (for example), but the operation names in Chinese and English are different. Internationalization is needed here.

Chinese internationalization documents:

monitor.alarm=盘古
create.host=盘古host

International documents in English:

monitor.alarm=pangu
create.host=pangu

The two internationalization files are actually stored in the form of key value. The log table records the key value, such as create.host. Then, when it is displayed to the user, first read the key value from the database, get the corresponding Chinese and English value from the key to the Chinese or English file, and then send the converted value back to the front end for display. In this way, the display can be switched well. After all, the value passed in the database is key. When log display is required, send a request to the back end, and the back end takes out the key value from the database. Generally, go back to load the Chinese and English internationalization file before system startup, and save the key value pair in the map. When the back end takes out the key from the database, you can directly take out the corresponding Chinese and English from the Chinese map or English map, and then send it back to the front end.

The above describes the key value stored in the database. How can the front end match the log query in the database. For example, the user will query the record of "create host", so the value passed back from the front end is "create host", and the value stored in the database is "create. Host". This does not match completely. In this case, you need to convert "create host" to "create. Host". My solution is as follows: first, the project is a spring project. I will first define a static variable and assign the value as follows:
`
import java.util.Map;

public class Constants {

public static Map ENGLISH_KEY_MAP = PropertiesUtils.readPropertiesAndReturnMap("/messages/messages_en.properties", false);

public static Map CHINESE_KEY_MAP = PropertiesUtils.readPropertiesAndReturnMap("/messages/messages_zh.properties", false);

public static Map CONFIG_MAP = PropertiesUtils.readPropertiesAndReturnMap("config.properties", true);

}`

@tombaeyens @tijsrademakers

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit den genannten Dateien /messages/messages_en.properties und /messages/messages_zh.properties, Constants und PropertiesUtils, und verfolge anschließend, wie Schlüssel für Operationsprotokolle gespeichert, angezeigt und abgefragt werden. Bestätige die Spring-Einstiegspunkte für den Abruf der Protokolle und die Sprachauswahl; abgeschlossen ist die Aufgabe, wenn der gespeicherte Schlüssel die Anzeige und Zuordnung auf Chinesisch und Englisch unterstützt, ohne den Datenbankwert zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, spring
Bereich
internationalization, localization
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.