Skip to content

Fix WinForm Culture Info Issue #3566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

Jack251970
Copy link
Contributor

Fix WinForm Culture Info Issue

For WinForm localization, we need to set culture info before creating application so that WinForm can follow the set language. This is helpful for plugins with WinForm windows.

To implement this, we also need to initialize settings so that we can get language code and initialize system language before changing culture info.

Test

  • Install one plugin with WinForm windows and change the application language to one language different from system language. Open the WinForm windows and check localization.

@prlabeler prlabeler bot added the bug Something isn't working label May 21, 2025
Copy link

gitstream-cm bot commented May 21, 2025

🥷 Code experts: no user but you matched threshold 10

Jack251970, onesounds have most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Resource/Internationalization.cs

Activity based on git-commit:

Jack251970 onesounds
MAY
APR 34 additions & 30 deletions
MAR 67 additions & 40 deletions
FEB 5 additions & 4 deletions
JAN 81 additions & 42 deletions
DEC

Knowledge based on git-blame:
Jack251970: 38%

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Activity based on git-commit:

Jack251970 onesounds
MAY 41 additions & 19 deletions
APR 34 additions & 83 deletions 104 additions & 38 deletions
MAR 142 additions & 94 deletions 10 additions & 0 deletions
FEB 10 additions & 4 deletions
JAN 17 additions & 4 deletions
DEC 1 additions & 1 deletions

Knowledge based on git-blame:
Jack251970: 26%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
MAY 8 additions & 3 deletions
APR 73 additions & 40 deletions 3 additions & 0 deletions
MAR 168 additions & 94 deletions
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions
DEC

Knowledge based on git-blame:
Jack251970: 67%

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

Copy link

gitstream-cm bot commented May 21, 2025

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

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot May 21, 2025 06:38
Copy link
Contributor

coderabbitai bot commented May 21, 2025

📝 Walkthrough

"""

Walkthrough

The changes refactor language code and culture initialization, moving system language setup and culture info application to explicit static methods. Application settings loading and error handling are shifted from the constructor to the static Main method, ensuring localization is configured before app instantiation. Font resource assignment is updated with null checks for safety.

Changes

File(s) Change Summary
Flow.Launcher.Core/Resource/Internationalization.cs Refactored system language code initialization to a static method; made language code field static; added a static method to centralize culture info changes, ensuring consistent culture updates for both main and current threads.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Enhanced font resource assignment after DI initialization; added null checks before updating application font resources to prevent null reference exceptions.
Flow.Launcher/App.xaml.cs Moved settings loading and error handling from constructor to static Main; made settings field static; centralized error handling in a static method; ensured culture setup before app instantiation.

Sequence Diagram(s)

sequenceDiagram
    participant Main as Main()
    participant Settings as Settings
    participant Intl as Internationalization
    participant App as App()

    Main->>Settings: Load()
    alt On error
        Main->>Main: Show error message and terminate
    end
    Main->>Intl: InitSystemLanguageCode()
    Main->>Intl: ChangeCultureInfo(Settings.Language)
    Main->>App: Create App instance
    App->>Settings: Use already loaded settings
Loading

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3376: Refactors asynchronous language initialization and plugin language directory management in the Internationalization class, directly related to language and culture setup changes.
  • Flow-Launcher/Flow.Launcher#3161: Adds system language option and related logic in Internationalization, complementing the refactoring of system language code handling.

Suggested labels

Dev branch only

Suggested reviewers

  • Jack251970
  • onesounds

Poem

In the warren of code, a new flow is born,
With culture and language now statically sworn.
Settings awake before dawn’s first light,
Fonts checked for nulls, all handled just right.
A hop, a leap—localization in sight!
🐇✨
"""

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7f52e2 and b099744.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Resource/Internationalization.cs (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Core/Resource/Internationalization.cs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

Copy link

@check-spelling-bot Report

🔴 Please review

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

❌ Errors and Warnings Count
❌ forbidden-pattern 22
⚠️ 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.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures WinForm windows are localized by loading user settings and setting the culture before creating the application, and adds early initialization for DI and UI resources.

  • Move settings load from the App constructor to Main and call InitSystemLanguageCode/ChangeCultureInfo before application startup
  • Refactor error handling into a static ShowErrorMsgBoxAndFailFast method
  • Update Settings to initialize DI services and theme fonts, and adjust culture-change logic in Internationalization

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Flow.Launcher/App.xaml.cs Load settings and set culture in Main, replace local error helper with a static method
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Add Settings.Initialize to wire up DI services and apply font resources, and update font setter
Flow.Launcher.Core/Resource/Internationalization.cs Introduce InitSystemLanguageCode and ChangeCultureInfo, streamline culture assignment logic
Comments suppressed due to low confidence (1)

Flow.Launcher.Core/Resource/Internationalization.cs:175

  • [nitpick] There are no existing tests covering the culture initialization and plugin metadata translation flow; consider adding unit or integration tests for InitSystemLanguageCode, ChangeCultureInfo, and UpdatePluginMetadataTranslations.
            await Task.Run(UpdatePluginMetadataTranslations);

@Jack251970 Jack251970 requested a review from jjw24 May 21, 2025 06:43
@jjw24 jjw24 added this to the Future milestone May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 min review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants