Skip to content

feat: provide i18n default resources#689

Merged
tbouffard merged 4 commits intomainfrom
feat/provide_18n_resources
Feb 24, 2025
Merged

feat: provide i18n default resources#689
tbouffard merged 4 commits intomainfrom
feat/provide_18n_resources

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 24, 2025

These resources were available in mxGraph but were missing in maxGraph.
The Storybook demo shows how to load the i18n resources and the npm package includes them.
The documentation now provides a dedicated page explaining how to use i18n.

In addition, the following stories were improved:

  • Control: display overlay image which lets delete the related cell
  • Permissions: add missing config to ensure that the connector image is always displayed

Notes

Covers #688

Summary by CodeRabbit

  • New Features

    • Enhanced localization support for key UI components with added language resources in English, German, and Chinese.
    • Updated image configurations improve the visual consistency of certain interactive controls.
  • Documentation

    • Added a comprehensive guide detailing the application’s internationalization approach for a smoother user experience.
    • Updated existing documentation to clarify the usage of the maxGraph API and its translation mechanisms.

These resources were available in mxGraph but were missing in maxGraph.
The Storybook demo shows how to load the i18n resources and the npm package includes them.
The documentation now provides a dedicated page explaining how to use i18n.

In addition, the following stories were improved:
- Control: display overlay image which lets delete the related cell
- Permissions: add missing config to ensure that the connector image is always displayed
@tbouffard tbouffard added the enhancement New feature or request label Feb 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

New localization files have been added for both the core and HTML packages supporting editor and graph interfaces in English, German, and Chinese. The package configuration now exports the i18n directory. Documentation has been updated with a new i18n usage guide and modifications to the API description. Additionally, Storybook configurations and related stories have been updated with image path adjustments, new configuration invocations, and enhanced logging for i18n resource loading. Minor documentation comment improvements were also made in the core view components.

Changes

File(s) Change Summary
packages/core/i18n/editor.txt, editor_de.txt, editor_zh.txt
packages/core/i18n/graph.txt, graph_de.txt, graph_zh.txt
Added new localization files containing key-value pairs for the Editor and Graph UI components in English, German, and Chinese.
packages/html/public/i18n/editor.txt, editor_de.txt, editor_zh.txt
packages/html/public/i18n/graph.txt, graph_de.txt, graph_zh.txt
Introduced new public i18n files for the Editor and Graph interfaces with corresponding translations.
packages/core/package.json Updated the exports and files sections to include the i18n directory ("./i18n/*": "./i18n/*" and "i18n" entry).
packages/core/src/view/GraphSelectionModel.ts,
packages/core/src/view/GraphView.ts
Updated documentation comments to use the @default tag for default property values.
packages/html/.storybook/preview.ts Integrated i18n resource logging by importing Client and Translations and using Translations.add with a callback logging resource load completion.
packages/html/stories/Control.stories.js,
Permissions.stories.js,
SwimLanes.stories.ts
Adjusted image source paths, added calls to configureImagesBasePath(), and improved inline comments (including TODOs) for better clarity.
packages/website/docs/development/high-level-api-description.md,
packages/website/docs/usage/i18n.md
Modified documentation: updated warning note formatting and added a new guide detailing the internationalization mechanism.

Sequence Diagram(s)

sequenceDiagram
    participant SP as Storybook Preview
    participant C as Client
    participant T as Translations
    participant L as Logger

    SP ->> C: Retrieve basePath for i18n
    SP ->> T: Call Translations.add(`${C.basePath}/i18n/*`, callback)
    T -->> L: Log "i18n resources loaded" upon callback execution
Loading

Possibly related PRs

Suggested labels

documentation

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tbouffard tbouffard marked this pull request as ready for review February 24, 2025 17:52
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
packages/core/i18n/editor_de.txt (1)

1-5:

Details

❓ Verification inconclusive

Consider enhancing German translations.

The translations are functionally correct but could be improved:

  1. "Uebersicht" could be "Übersicht" if UTF-8 encoding is supported
  2. Consider adding a comment header to specify the encoding used

Let's verify the encoding support and consistency across language files:


🏁 Script executed:

#!/bin/bash
# Check encoding of i18n files and look for similar patterns
file packages/core/i18n/*.txt packages/html/public/i18n/*.txt

Length of output: 521


Enhance German Translations & Verify Encoding in i18n Files

  • Update the translation for "outline" in packages/core/i18n/editor_de.txt from "Uebersicht" to "Übersicht" if your environment supports UTF-8.
  • The initial encoding check failed because the file command was not found; please manually verify that all i18n text files (e.g. in packages/core/i18n/ and packages/html/public/i18n/) are encoded in UTF-8.
  • Consider adding an encoding comment header (e.g., # -*- coding: utf-8 -*-) at the top of these files for greater clarity.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: askZoom=Zoom eingeben (%) properties=Eigenschaften outline=Uebersi...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...om eingeben (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=H...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~3-~3: Hier scheint es einen Fehler zu geben.
Context: ...en (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_MERGED_MATCH)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...haften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/html/public/i18n/editor_de.txt (1)

1-5:

Details

❓ Verification inconclusive

Verify if file duplication is necessary.

This file is identical to packages/core/i18n/editor_de.txt. Consider:

  1. Using a build step to copy files if needed
  2. Creating a shared i18n package
  3. Using symlinks

Let's check if other language files follow the same pattern:


🏁 Script executed:

#!/bin/bash
# Compare i18n files between core and html packages
diff -r packages/core/i18n/ packages/html/public/i18n/

Length of output: 56


Action: Revisit your i18n file reuse strategy.
The German translation file in the html package (packages/html/public/i18n/editor_de.txt) appears to be identical to the one in the core package (packages/core/i18n/editor_de.txt). Please manually verify that this duplication is intentional. If it is acceptable, consider simplifying maintenance by:

  • Implementing a build step to copy/sync the file
  • Creating a shared i18n package accessible by both modules
  • Using symlinks

Document the decision or update the strategy accordingly.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: askZoom=Zoom eingeben (%) properties=Eigenschaften outline=Uebersi...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...om eingeben (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=H...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~3-~3: Hier scheint es einen Fehler zu geben.
Context: ...en (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_MERGED_MATCH)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...haften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/html/stories/Permissions.stories.js (1)

216-229: Consider enhancing the Permission class implementation.

The Permission class could be improved:

  1. Add TypeScript for better type safety
  2. Use private fields for better encapsulation
  3. Consider using a builder pattern for complex permission combinations

Example enhancement:

class Permission {
  #locked: boolean;
  #createEdges: boolean;
  #editEdges: boolean;
  #editVertices: boolean;
  #cloneCells: boolean;

  constructor({
    locked = false,
    createEdges = true,
    editEdges = true,
    editVertices = true,
    cloneCells = true
  } = {}) {
    this.#locked = locked;
    this.#createEdges = createEdges;
    this.#editEdges = editEdges;
    this.#editVertices = editVertices;
    this.#cloneCells = cloneCells;
  }

  apply(graph: Graph): void {
    graph.setConnectable(this.#createEdges);
    graph.setCellsLocked(this.#locked);
  }
}
packages/html/.storybook/preview.ts (1)

23-26: Add error handling for i18n resource loading.

While the implementation works, it could be more robust with proper error handling.

 defaultLogger.info('[sb-config] Loading i18n resources for Graph...');
-Translations.add(`${Client.basePath}/i18n/graph`, null, (): void => {
+Translations.add(`${Client.basePath}/i18n/graph`, null, 
+  (): void => {
   defaultLogger.info('[sb-config] i18n resources loaded for Graph');
+  },
+  (error): void => {
+    defaultLogger.error('[sb-config] Failed to load i18n resources:', error);
 });
packages/core/i18n/graph_de.txt (1)

7-7: Update to modern German spelling.

The word "Schliessen" should use the modern German spelling with "ß".

-close=Schliessen
+close=Schließen
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: Hier scheint es einen Fehler zu geben.
Context: ...klicken um Orientierung zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbreche...

(AI_DE_MERGED_MATCH)

packages/website/docs/development/high-level-api-description.md (2)

7-10: Emphasizing the Need for Rework
Changing from a simple note to a warning here effectively signals that this content is both adapted and in need of an update. Ensure that a follow-up is scheduled to rework this section so it fully reflects maxGraph’s current state.


121-132: Link Update and Image Section Note
The added link to the i18n documentation is a useful pointer for users looking for detailed internationalization guidance. In the Images section, the note indicates that the content (sourced from mxGraph) still requires updating. Consider rephrasing or updating this note once the image resources and related documentation reflect maxGraph's current implementation to avoid any confusion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e15f34c and 20f07e4.

📒 Files selected for processing (21)
  • packages/core/i18n/editor.txt (1 hunks)
  • packages/core/i18n/editor_de.txt (1 hunks)
  • packages/core/i18n/editor_zh.txt (1 hunks)
  • packages/core/i18n/graph.txt (1 hunks)
  • packages/core/i18n/graph_de.txt (1 hunks)
  • packages/core/i18n/graph_zh.txt (1 hunks)
  • packages/core/package.json (1 hunks)
  • packages/core/src/view/GraphSelectionModel.ts (1 hunks)
  • packages/core/src/view/GraphView.ts (1 hunks)
  • packages/html/.storybook/preview.ts (3 hunks)
  • packages/html/public/i18n/editor.txt (1 hunks)
  • packages/html/public/i18n/editor_de.txt (1 hunks)
  • packages/html/public/i18n/editor_zh.txt (1 hunks)
  • packages/html/public/i18n/graph.txt (1 hunks)
  • packages/html/public/i18n/graph_de.txt (1 hunks)
  • packages/html/public/i18n/graph_zh.txt (1 hunks)
  • packages/html/stories/Control.stories.js (1 hunks)
  • packages/html/stories/Permissions.stories.js (2 hunks)
  • packages/html/stories/SwimLanes.stories.ts (1 hunks)
  • packages/website/docs/development/high-level-api-description.md (2 hunks)
  • packages/website/docs/usage/i18n.md (1 hunks)
✅ Files skipped from review due to trivial changes (11)
  • packages/core/i18n/editor.txt
  • packages/html/public/i18n/editor_zh.txt
  • packages/core/i18n/graph_zh.txt
  • packages/html/stories/Control.stories.js
  • packages/html/public/i18n/editor.txt
  • packages/html/stories/SwimLanes.stories.ts
  • packages/core/i18n/editor_zh.txt
  • packages/core/src/view/GraphSelectionModel.ts
  • packages/html/public/i18n/graph.txt
  • packages/core/i18n/graph.txt
  • packages/core/src/view/GraphView.ts
🧰 Additional context used
🪛 LanguageTool
packages/core/i18n/editor_de.txt

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: askZoom=Zoom eingeben (%) properties=Eigenschaften outline=Uebersi...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...om eingeben (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=H...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~3-~3: Hier scheint es einen Fehler zu geben.
Context: ...en (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_MERGED_MATCH)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...haften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/core/i18n/graph_de.txt

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: alreadyConnected=Knoten schon verbunden containsValidationErrors=Enthält Validie...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...idationErrors=Enthält Validierungsfehler updatingDocument=Aktualisiere Dokument. ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~3-~3: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...t=Aktualisiere Dokument. Bitte warten... updatingSelection=Aktualisiere Markierun...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...Aktualisiere Markierung. Bitte warten... collapse-expand=Einklappen/Ausklappen do...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~5-~5: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ..... collapse-expand=Einklappen/Ausklappen doubleClickOrientation=Doppelklicken um ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~6-~6: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...=Doppelklicken um Orientierung zu ändern close=Schliessen error=Fehler done=Ferti...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~7-~7: Hier scheint es einen Fehler zu geben.
Context: ...klicken um Orientierung zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbreche...

(AI_DE_MERGED_MATCH)


[uncategorized] ~8-~8: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ... zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~9-~9: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...lose=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~10-~10: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...rror=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/html/public/i18n/editor_de.txt

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: askZoom=Zoom eingeben (%) properties=Eigenschaften outline=Uebersi...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...om eingeben (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=H...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~3-~3: Hier scheint es einen Fehler zu geben.
Context: ...en (%) properties=Eigenschaften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_MERGED_MATCH)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...haften outline=Uebersicht tasks=Aufgaben help=Hilfe

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/html/public/i18n/graph_de.txt

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: alreadyConnected=Knoten schon verbunden containsValidationErrors=Enthält Validie...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...idationErrors=Enthält Validierungsfehler updatingDocument=Aktualisiere Dokument. ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...Aktualisiere Markierung. Bitte warten... collapse-expand=Einklappen/Ausklappen do...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~5-~5: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ..... collapse-expand=Einklappen/Ausklappen doubleClickOrientation=Doppelklicken um ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~6-~6: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...=Doppelklicken um Orientierung zu ändern close=Schliessen error=Fehler done=Ferti...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~7-~7: Hier scheint es einen Fehler zu geben.
Context: ...klicken um Orientierung zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbreche...

(AI_DE_MERGED_MATCH)


[uncategorized] ~8-~8: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ... zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~9-~9: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...lose=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~10-~10: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...rror=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)

🔇 Additional comments (6)
packages/core/package.json (1)

29-29: LGTM! Proper configuration for i18n resources.

The i18n directory is correctly added to both exports and files sections, making the localization resources available to package consumers.

Also applies to: 37-37

packages/html/stories/Permissions.stories.js (1)

32-32: LGTM! Proper configuration of image base path.

The configureImagesBasePath function is correctly imported and called before creating the graph container, ensuring the connector image works properly.

Also applies to: 48-49

packages/html/public/i18n/graph_zh.txt (1)

1-11: LGTM! Chinese translations are well-structured and complete.

The translations cover all essential UI strings and maintain consistent formatting throughout the file.

packages/html/public/i18n/graph_de.txt (1)

1-11: Maintain consistency with core translations.

This file should mirror any updates made to packages/core/i18n/graph_de.txt, including the spelling correction of "Schliessen" to "Schließen".

🧰 Tools
🪛 LanguageTool

[uncategorized] ~1-~1: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: alreadyConnected=Knoten schon verbunden containsValidationErrors=Enthält Validie...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~2-~2: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...idationErrors=Enthält Validierungsfehler updatingDocument=Aktualisiere Dokument. ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~4-~4: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...Aktualisiere Markierung. Bitte warten... collapse-expand=Einklappen/Ausklappen do...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~5-~5: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ..... collapse-expand=Einklappen/Ausklappen doubleClickOrientation=Doppelklicken um ...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~6-~6: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...=Doppelklicken um Orientierung zu ändern close=Schliessen error=Fehler done=Ferti...

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~7-~7: Hier scheint es einen Fehler zu geben.
Context: ...klicken um Orientierung zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbreche...

(AI_DE_MERGED_MATCH)


[uncategorized] ~8-~8: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ... zu ändern close=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~9-~9: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...lose=Schliessen error=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)


[uncategorized] ~10-~10: Das sieht falsch platziert oder unnötig aus. Überlegen Sie, es zu löschen.
Context: ...rror=Fehler done=Fertig cancel=Abbrechen ok=OK

(AI_DE_GGEC_UNNECESSARY_SPACE)

packages/website/docs/usage/i18n.md (2)

1-4: Solid Front Matter Metadata
The front-matter metadata (lines 1–4) is clear and properly sets the context for the i18n documentation page. This well-structured header will help in correct sidebar positioning and page description.


6-44: Overall Clarity and Completeness
This new i18n documentation file thoroughly explains how to configure and leverage maxGraph’s internationalization features. The examples provided, along with the clear step-by-step instructions for loading resources, greatly enhance developer usability.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/core/src/util/Translations.ts (1)

69-71: Consider enhancing the default resources documentation.

While the simplified instruction is clear, consider adding:

  • A brief description of what the default resources contain
  • The expected location of these resources
  • The supported languages (as mentioned in the PR: English, German, and Chinese)
 * ## Loading default resources
 *
-* Call {@link loadResources} to load the default resources file for both {@link Graph} and {@link Editor}.
+* Call {@link loadResources} to load the default resources file for both {@link Graph} and {@link Editor}.
+* The default resources include translations for UI elements in English, German (de), and Chinese (zh).
+* These resources are located in the `i18n` directory and follow the naming pattern:
+* - editor.txt, editor_de.txt, editor_zh.txt
+* - graph.txt, graph_de.txt, graph_zh.txt
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20f07e4 and d59215a.

📒 Files selected for processing (2)
  • packages/core/src/util/Translations.ts (2 hunks)
  • packages/website/docs/usage/i18n.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/website/docs/usage/i18n.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (2)
packages/core/src/util/Translations.ts (2)

41-45: LGTM! Documentation format improvement.

The change from JavaScript to XML format in the code block better reflects the actual format used in the editor configuration file.


73-377: LGTM! Robust i18n implementation.

The Translations class provides a comprehensive and well-designed internationalization solution with:

  • Flexible resource loading (sync/async)
  • Proper language detection and fallback
  • Robust error handling
  • Extensible design
🧰 Tools
🪛 Biome (1.9.4)

[error] 72-377: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 187-187: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 372-372: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)

@tbouffard tbouffard merged commit 9f18fba into main Feb 24, 2025
7 checks passed
@tbouffard tbouffard deleted the feat/provide_18n_resources branch February 24, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant