Skip to content

Conversation

Yusyuriv
Copy link
Member

@Yusyuriv Yusyuriv commented Jun 9, 2024

Fixes #1292, closes PR #1392.

Issue

On startup, Flow was waiting until plugins are loaded before loading any localization files. If there are Python/Node plugins installed without the Python/Node runtime specified in settings, it would show a hard-coded message in English (and a few other hard-coded messages).

Changes

What I did:

  1. Moved internationalization initialization higher, above loading plugins
  2. Extracted the hard-coded messages from above into en.xaml
  3. Since now it doesn't wait for plugins to load first, and those directories are now unknown at the time of initialization, removed adding plugins' translation directories from Internationalization constructor
  4. Made PluginManager call AddPluginLanguageDirectories and ChangeLanguage after the plugins have been loaded.

Testing

  • The startup messages are now localized
  • Flow launches and seems to work correctly

Summary by CodeRabbit

  • New Features

    • Enhanced internationalization support with new message prompts and translations for better language consistency.
  • Bug Fixes

    • Improved handling of failed plugin initialization with detailed internationalized error messages.
  • Refactor

    • Refined message prompt constructions and formatting for better readability and maintainability.
    • Reordered settings and language assignments for smoother plugin loading.
  • Localization

    • Added new translation strings for English and Russian language files related to plugin prompts and error messages.

@Yusyuriv Yusyuriv added bug Something isn't working kind/i18n labels Jun 9, 2024
@Yusyuriv Yusyuriv self-assigned this Jun 9, 2024
@taooceros
Copy link
Member

Moved internationalization initialization higher, above loading plugins

I think internationalization requires loading plugin (for loading plugin resources). Maybe that needs to be changed

@Yusyuriv
Copy link
Member Author

Moved internationalization initialization higher, above loading plugins

I think internationalization requires loading plugin (for loading plugin resources). Maybe that needs to be changed

Yes, which is why I only load Flow's language first (so plugin loading code could display localized errors) and then let PluginManager class add plugins' languages to resources after all plugins have been loaded.

This comment has been minimized.



private void AddPluginLanguageDirectories()
internal void AddPluginLanguageDirectories()
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about making this method accepting a IEnumerable or something similar instead of referencing back to the PluginManager?

Copy link
Member Author

Choose a reason for hiding this comment

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

And pass it from PluginManager like this? Seems logical to me.

InternationalizationManager.Instance.AddPluginLanguageDirectories(GetPluginsForInterface<IPluginI18n>());

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Yusyuriv Yusyuriv marked this pull request as ready for review June 27, 2024 05:19
Copy link
Contributor

coderabbitai bot commented Jun 27, 2024

Walkthrough

The recent updates enhance the internationalization capability of the Flow.Launcher project. Key changes include integrating the InternationalizationManager for better handling of message prompts and translations across the application. This ensures language support and consistency, particularly for plugin installation and error handling messages. Additionally, the Python download dialog is now translatable, expanding the application's accessibility to a broader audience.

Changes

Files Change Summary
Flow.Launcher.Core/ExternalPlugins/Environments/... Refactored to use InternationalizationManager for message formatting and translations.
Flow.Launcher.Core/Plugin/PluginManager.cs Enhanced internationalization, updated initialization process, and improved code readability
Flow.Launcher.Core/Resource/Internationalization.cs Made AddPluginLanguageDirectories method internal and added parameter handling
Flow.Launcher/App.xaml.cs Reordered assignments for better initialization flow and removed temporary fixes
Flow.Launcher/Languages/en.xaml Added new strings for plugin installation prompts and failure messages
Flow.Launcher/Languages/ru.xaml Added translations for new strings related to plugin installation and error messages

Assessment against linked issues

Objective Addressed Explanation
Make Python download dialog translatable (#1292)

Poem

In every plugin, every file,
Flow learns a language, mile by mile. 🌐
With words that greet and errors rare,
Now speaks the world, with greater care.
Translations bloom, and bugs take flight,
A coder's dream, a rabbit's delight. 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

gitstream-cm[bot]
gitstream-cm bot previously requested changes Jun 27, 2024
Copy link

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

This PR contains a TODO statement. Please check to see if they should be removed.

Copy link

gitstream-cm bot commented Jun 27, 2024

🥷 Code experts: jjw24, VictoriousRaptor

jjw24, VictoriousRaptor have most 👩‍💻 activity in the files.
jjw24 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 60%

Flow.Launcher.Core/Plugin/PluginManager.cs

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 4%

Flow.Launcher.Core/Resource/Internationalization.cs

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN
MAY 3 additions & 6 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 10%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN
MAY 1 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 16%

Flow.Launcher/Languages/en.xaml

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN 2 additions & 2 deletions
MAY 4 additions & 3 deletions
APR 6 additions & 6 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 7%

Flow.Launcher/Languages/ru.xaml

Activity based on git-commit:

jjw24 VictoriousRaptor
JUN 23 additions & 1 deletions
MAY 49 additions & 9 deletions
APR 2 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
jjw24: 98%

To learn more about /:\ gitStream - Visit our Docs

Copy link

gitstream-cm bot commented Jun 27, 2024

This PR is 65.93406593406593% new code.

Copy link

gitstream-cm bot commented Jun 27, 2024

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@prlabeler prlabeler bot added Code Refactor enhancement New feature or request labels Jun 27, 2024
Copy link
Contributor

@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: 2

This comment has been minimized.

@Yusyuriv Yusyuriv dismissed gitstream-cm[bot]’s stale review June 27, 2024 05:37

The PR does not contain a todo

{
MessageBox.Show(
$"Unable to set {Language} executable path, please try from Flow's settings (scroll down to the bottom).");
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering we've implemented MessageboxEx so maybe it's better to use it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's implemented in Flow.Launcher project while this file is in Flow.Launcher.Core. I don't know of a way to do that (besides moving MessageBoxEx to a different project) without introducing a circular dependency, and moving MessageBoxEx to a different project would be beyond the scope of this PR.

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 1
⚠️ non-alpha-in-dictionary 13

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- Startup -->
<system:String x:Key="runtimePluginInstalledChooseRuntimePrompt">
Flow определил, что вы установили {0} плагины, которым требуется {1} для работы. Скачать {1}?
Copy link
Member

Choose a reason for hiding this comment

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

Just fyi, if this language update hasn't been added to Crowdin, pretty sure they will get reverted back to English or overridden with updates coming from Crowdin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working kind/i18n

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Python download dialog translatable

4 participants