Skip to content
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

Feature/Automated Key Naming Convention Suggestion for Localize-It Action #399

Merged
merged 9 commits into from
May 31, 2024

Conversation

JPilson
Copy link
Contributor

@JPilson JPilson commented Apr 21, 2024

Pull Request Description

This pull request introduces an enhancement to the Localize-It Action, addressing the manual adjustment requirement for key naming conventions during string extraction. The implemented feature automates key naming convention suggestions, significantly improving user experience and code consistency.


Changes Implemented:

  • Automated Key Naming Convention Suggestions: Integrated functionality to automatically suggest key naming conventions based on user preferences or project settings.

  • Support for CamelCase , PascalCase and Snake_case: Initial implementation covers CamelCase and Snake_case naming conventions.

Future Considerations:

  • Expansion of Supported Naming Conventions: Consider adding support for additional naming conventions based on user feedback and industry standards. This could include, kebab-case, etc.

Next Steps:

  • Review and Merge: Request code review and merge the changes once approved.

Show Case:

Before

image

After

image

JPilson added 8 commits April 16, 2024 20:33
New methods have been added to convert keys to either camel or snake case depending on a boolean flag. These methods are used to format the text that is input into the Add Dialog in 'LocalizeItAction' class. This improves the versatility of key handling within the project.
Implemented a new setting, `getCaseFormat`, in the `ProjectSettings` interface, returning the naming convention used. Also extended corresponding implementations (`DefaultPreset`, `VueI18nPreset`, `ReactI18NextPreset`, `SettingsTestPreset`) to return `NamingConvention.CAMEL_CASE`. A new enum `NamingConvention` was created for this, with options `SNAKE_CASE` and `CAMEL_CASE`.
This update enables the user to specify a key naming convention (Camel Case or Snake Case) for extracted translations. This option is made available in the settings panel, and has been included in the project-specific configuration and state management for the project settings component.
… to NamingConvention

This commit adds a new attribute, `caseFormat`, to the `ProjectSettingsState` class. It also introduces a static method `fromSelector` in the `NamingConvention` class to transform a string into a NamingConvention enum. The transformation in `ProjectSettingsComponentState` has been updated  to use this new method.
Refactored convertKeyToNamingCase method to include project-specific naming conventions. Now, it adapts to the naming convention specified in the project settings. This change enhances flexibility by catering to individual project preferences.
Updated naming convention features by simplifying key case formatter construction and expanding the naming convention enum. Also performed a refactor to layout and formatting across various files for improved readability. Added new test cases to validate the update to naming convention.
Moved key naming convention conversion logic into NamingConvention enum. This simplifies the code in LocalizeItAction and makes the conversion function easily reusable. Also added support for uppercase snake and camel cases.
Moved `NamingConvention` from the settings package to a new settings.presets package. This involved modifying various import statements across the application and updating methods that utilised this enum. Increased the `KeyCaseFormater` minimum and preferred width to 200 for better UI rendering.
Copy link

codecov bot commented Apr 21, 2024

Codecov Report

Attention: Patch coverage is 65.90909% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 31.41%. Comparing base (3dd4117) to head (4583404).
Report is 23 commits behind head on main.

Files Patch % Lines
...li/easyi18n/settings/ProjectSettingsComponent.java 0.00% 6 Missing ⚠️
...a/de/marhali/easyi18n/action/LocalizeItAction.java 0.00% 2 Missing ⚠️
...syi18n/settings/ProjectSettingsComponentState.java 0.00% 2 Missing ⚠️
...arhali/easyi18n/settings/ProjectSettingsState.java 66.66% 1 Missing and 1 partial ⚠️
...li/easyi18n/settings/presets/NamingConvention.java 96.00% 1 Missing ⚠️
.../easyi18n/settings/presets/ReactI18NextPreset.java 0.00% 1 Missing ⚠️
...rhali/easyi18n/settings/presets/VueI18nPreset.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #399      +/-   ##
==========================================
+ Coverage   31.32%   31.41%   +0.09%     
==========================================
  Files         104      108       +4     
  Lines        1874     1897      +23     
  Branches      317      323       +6     
==========================================
+ Hits          587      596       +9     
- Misses       1215     1235      +20     
+ Partials       72       66       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The main modification is in `NamingConvention.java` replacing the enumeration `CAMEL_CASE_UPPERCASE` with `PASCAL_CASE`. This change can help to improve the readability of the code by reducing the verbosity of names and ensure convention consistency. Also, a new test file `NamingConventionTest.java` has been introduced to ensure correctness and stability of the code against these modifications.
@JPilson
Copy link
Contributor Author

JPilson commented Apr 21, 2024

@marhali check this out

@marhali marhali merged commit 5428ae3 into marhali:main May 31, 2024
7 checks passed
@marhali
Copy link
Owner

marhali commented May 31, 2024

Thanks for your contribution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automated Key Naming Convention Suggestion for Localize-It Action
2 participants