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

feat: "Ignore Array" and "Item Key Formatting Style" options #38

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

HappyAreaBean
Copy link
Contributor

Overview

This PR introduces two new options, "Ignore Array" and "Item Key Formatting Style". These options are added to the "Additional Options" accordion in the user interface.

圖片

The motivation behind adding the new options

First, I love this tool; it's time-saving for generating Triton collections. While using this tool, I noticed that dealing with multi-line types of messages is a little bit inconvenient, especially when translating scoreboards, as scoreboards do not work the same way as messages.

Item key formatting, well, this is mainly personal preferences but since the generator output is following the message file's key, when the messages file have like: Messages.INLOBBY.JOIN_MESSAGE is a little bit inconvenient to read, when me much more prefer consistency wanting all the item key are lowercase. This option added the flexibility for that.

I believe that these new options enhance the usability of the tool and offer users more control over the output. By providing these choices, users can customize the conversion process according to their specific needs.

Changes Made

  • Implemented the "Ignore Array" option to preserve all list-like data during conversion. This option uses a custom recursive function, deepCopyObject, to ensure ignored arrays data are copied from the main language file.
  • Added the "Item Key Formatting Style" option, allowing users to choose from three styles: "Default," "All Lowercase," and "All Uppercase." The option provides users with more choices for item key formatting.

"Ignore Array" option

  • To enable the "Ignore Array" option, check the corresponding checkbox in the "Additional Options" accordion.
  • This option preserves all list-like data during conversion, making it convenient to handle multi-line messages like scoreboards.
  • A tooltip provides an explanation of list-like data and the behavior of the "Ignore Array" option.

"Item Key Formatting Style" option

  • To select the "Item Key Formatting Style," use the drop-down menu in the "Additional Options" accordion.
  • Three options are available:
    • Default: Follows the file key format (e.g., plugin.Messages.Prefix).
    • All Lowercase: Converts all item keys to lowercase (e.g., plugin.messages.prefix).
    • All Uppercase: Converts all item keys to uppercase (e.g., PLUGIN.MESSAGES.PREFIX).

…e "Additional Options" accordion.

- Added "Ignore Array" and "Force Item Key Lowercase" options to the "Additional Options" accordion.
- The "Ignore Array" option allows users to preserve all list-like data during conversion.
- Included a tooltip with an explanation of list-like data and the option's behavior.
- The "Force Item Key Lowercase" option will make item key lowercase during the conversion process.

The "Ignore Array" option in the "Additional Options" accordion allows users to preserve any list-like data during the conversion process. The option is accompanied by a tooltip that provides a brief explanation of list-like data and how the option affects the conversion.

The implementation includes a `deepCopy` function, which is a custom recursive function used to create deep copies of objects and arrays. This function ensures ignored arrays data are copied from the main language file.
Allow users to select different item key formatting styles: original, lowercase, or uppercase. This replaces the Force Key Lowercase option, providing users with more choices for item key formatting. The option is still available under the "Additional Options" accordion.
Replace Original Conventions option in item key format options to Default.
Modified the "`handleIgnoreArray`" method to correctly store main language values for each unique key path, preventing array value duplication when the "`ignoreArray`" option is enabled.

Before the modification, `handleIgnoreArray` only stored the `key`, not the full key path. This resulted in the same value being used for different keys that shared the same `key` at different paths, such as `foo.bar.item.lore` or `bar.foo.item.lore`.
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.

1 participant