Skip to content

Added some parts that have not yet been internationalized#1817

Merged
toddtarsi merged 3 commits into
SeleniumHQ:trunkfrom
fernandozw:trunk
Apr 25, 2024
Merged

Added some parts that have not yet been internationalized#1817
toddtarsi merged 3 commits into
SeleniumHQ:trunkfrom
fernandozw:trunk

Conversation

@fernandozw

@fernandozw fernandozw commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

User description

Thanks for contributing to the Selenium IDE!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Type

enhancement, documentation


Description

  • Refactored CommandLocatorField component for improved code structure and readability.
  • Added new translations for menu items and test core descriptions in I18N.ts.
  • Enhanced pluralization function to support language-specific rules in testEditor.ts.
  • Updated dynamic language references in CommandEditor and projectView.ts for better internationalization support.

Changes walkthrough

Relevant files
Enhancement
LocatorField.tsx
Refactor and Enhance CommandLocatorField Component             

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/CommandFields/LocatorField.tsx

  • Refactored the CommandLocatorField component for better readability
    and maintainability.
  • Updated the state management and event handling within the component.
  • Improved the handling of language-specific labels for UI elements.
  • +1121/-1119
    TestCommandEditor.tsx
    Integrate Dynamic Language References in CommandEditor     

    packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/TestCommandEditor.tsx

  • Integrated dynamic language map references for field names and notes
    in the CommandEditor component.
  • +6/-2     
    testEditor.ts
    Enhance Pluralization Function for Internationalization   

    packages/selenium-ide/src/main/session/controllers/Menu/menus/testEditor.ts

  • Modified the pluralize function to append 's' based on language
    settings, enhancing internationalization support.
  • +6/-2     
    projectView.ts
    Update Label Retrieval for Menu Item                                         

    packages/selenium-ide/src/main/session/controllers/Menu/menus/projectView.ts

  • Updated label retrieval for 'Refresh Playback Window' to support
    internationalization.
  • +1/-1     
    Documentation
    I18N.ts
    Update Translations for Menu Items and Test Core                 

    packages/selenium-ide/src/browser/enums/I18N.ts

  • Added new menu item translations for 'Refresh Playback Window' in both
    English and Chinese.
  • Introduced new keys for 'Window Handle Name' and its description in
    the test core section for both languages.
  • +8/-2     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @CLAassistant

    CLAassistant commented Apr 23, 2024

    Copy link
    Copy Markdown

    CLA assistant check
    All committers have signed the CLA.

    @qodo-code-review

    Copy link
    Copy Markdown

    PR Description updated to latest commit (e86052d)

    @qodo-code-review

    Copy link
    Copy Markdown

    PR Review

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves a significant amount of changes across multiple files, including internationalization updates and refactoring of existing code. The changes are spread across TypeScript and JSON files, affecting UI components, language handling, and command definitions. Reviewing this PR requires a good understanding of the project's architecture and internationalization approach.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The removal of the pluralize function from 'testEditor.ts' and its inline replacement might not handle pluralization correctly for all languages. The new implementation assumes only English ('s' suffix) without considering other language rules.

    Code Clarity: The changes in 'CommandLocatorField.tsx' introduce a large block of command definitions which might be better placed in a separate file or module to improve maintainability and separation of concerns.

    🔒 Security concerns

    No


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    @fernandozw

    Copy link
    Copy Markdown
    Contributor Author

    @toddtarsi In this PR, I have added some parts that have not yet been internationalized.

    @qodo-code-review

    Copy link
    Copy Markdown

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Maintainability
    Improve code readability by ensuring consistent spacing in object properties.

    Ensure consistent spacing around the colon for object properties to improve readability
    and maintain coding standards.

    packages/selenium-ide/src/browser/enums/I18N.ts [67-68]

     resetPlaybackWindows: "Reset Playback Windows",
    -refreshPlaybackWindow:"Refresh Playback Window"
    +refreshPlaybackWindow: "Refresh Playback Window"
     
    Enhance readability by adding spaces around operators and after colons.

    Add a space after the colon in the ternary operator for consistency and readability.

    packages/selenium-ide/src/main/session/controllers/Menu/menus/testEditor.ts [15]

    -const suffix=language==='en'?'s':''
    +const suffix = language === 'en' ? 's' : ''
     
    Best practice
    Enhance version control friendliness by adding a trailing comma.

    Add a trailing comma to the last property in the object for better version control
    practices and easier code modification.

    packages/selenium-ide/src/browser/enums/I18N.ts [68]

    -refreshPlaybackWindow: "Refresh Playback Window"
    +refreshPlaybackWindow: "Refresh Playback Window",
     
    Improve code readability and maintain modern standards using template literals.

    Use template literals for string concatenation to improve readability and consistency with
    modern JavaScript practices.

    packages/selenium-ide/src/main/session/controllers/Menu/menus/testEditor.ts [16]

    -return num < 2 ? str : str+suffix;
    +return num < 2 ? str : `${str}${suffix}`;
     
    Enhancement
    Simplify property access and improve code readability using destructuring.

    Use destructuring for languageMap.testCore to simplify the code and improve readability.

    packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/TestCommandEditor.tsx [88-89]

    -fieldName={languageMap.testCore.windowHandleName}
    -note={languageMap.testCore.windowHandleNameNote}
    +const { windowHandleName, windowHandleNameNote } = languageMap.testCore;
    +fieldName={windowHandleName}
    +note={windowHandleNameNote}
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    
    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    

    See the improve usage page for a comprehensive guide on using this tool.

    @fernandozw

    Copy link
    Copy Markdown
    Contributor Author
    test11

    @toddtarsi toddtarsi left a comment

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

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

    @fernandozw - This LGTM! 🚀 Thank you for the awesome contributions!

    For maintenance purposes, I'd like to later source the english commandMap strings from the side-model package here (but we can do later, language support comes first, we can consolidate command maps later.)

    https://github.com/SeleniumHQ/selenium-ide/blob/trunk/packages/side-model/src/Commands.ts

    Would you also be able to increment packages/selenium-ide? That way we can put out a new binary beta x.9 with your changes?

    @fernandozw

    Copy link
    Copy Markdown
    Contributor Author

    @toddtarsi I may not add new features for the time being, I will wait for your good news first, haha

    @toddtarsi

    Copy link
    Copy Markdown
    Contributor

    @fernandozw - Absolutely, you are doing great. I actually meant I can do that later for my own cleanup. It's perfect that you're focusing on internationalization. I can't thank you enough for the great work. Let's merge this and I'll increment the ide to cut a release later today

    @fernandozw

    Copy link
    Copy Markdown
    Contributor Author

    @toddtarsi I have a new commit for this pr:

    1. Fixed a serious bug. Since startDriver monitors session.driver.stopped, startDriver will always be called as long as session.driver.stopped. However, when this.stopped = false in startProcess, it will cause the driver type to be switched. Unable to switch, it kept prompting that the address is occupied, so I commented this.stopped = false, so that after processing, the driver can switch between electron and chrome at will.
    2. As I said, since startDriver listens to session.driver.stopped, after the driver terminates abnormally (such as killing the driver's process through the console), startDriver will not automatically restart, causing the browser to fail to start during playback, so I The restart driver function has been added to System to solve the startup problem after the driver terminates abnormally.
    3. In addition, I also processed the default value of Selected Playback Browser when Use Bidi is No. The given default value is electron-version.
    4. Also when we switched Use Bidi from No to Yes for the first time, the value of Selected Playback Browser was empty because we did not select the driver at all. I also processed it and gave the default value to electron-version.
    5. At this point, Bidi settings will no longer be an Experimental/Non working function. Except for the inability to record through the browser (I want to know your follow-up plans here), other functions can be used normally.
    start index restart

    }
    }
    >
    {languageMap.systemConfig.restartDriver}

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

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

    This is so smart!

    @toddtarsi

    Copy link
    Copy Markdown
    Contributor

    Okay, CI is running now. If it passes. we'll merge and increment. You are amazing @fernandozw

    @toddtarsi

    Copy link
    Copy Markdown
    Contributor

    @fernandozw - CI passed, but it looks like you have to sign the Contributor License Agreement thing. Can you sign the CLA using the link in the checks section?

    @fernandozw

    Copy link
    Copy Markdown
    Contributor Author

    @fernandozw - CI passed, but it looks like you have to sign the Contributor License Agreement thing. Can you sign the CLA using the link in the checks section?

    @toddtarsi I'm very sorry. The username and email address of my previous local commit were different from those of github, which caused it to fail the CLA check. Now the commit information has been modified and you can merge it. Sorry, it was my carelessness.

    @toddtarsi

    Copy link
    Copy Markdown
    Contributor

    @fernandozw - You are 🥇 kicking ass, and this CLA used to bite me all of the time.

    @toddtarsi toddtarsi merged commit 353e2f4 into SeleniumHQ:trunk Apr 25, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants