Skip to content

Add lang file updates on version change #5072

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

Merged

Conversation

APickledWalrus
Copy link
Member

Description

This PR enables lang file updates when Skript detects a version change.
There are a few questions where I'm looking for input though:

  • Should we allow addons to opt into this feature? Should it only be for Skript? My thought is that addon opt in would only be possible for addons that handle language files the same as Skript (I'm not sure any do tbh)
  • Right now, it always updates and creates a backup of a lang file if a version change is detected. This is because Skript has no built-in capability of detecting differences in values of Config objects, only the actual keys themselves. Should we add a way for Skript to check if the values themselves have changed? It might result in slightly longer startup time when the version changes, but it might be better than just assuming it's changed.

Target Minecraft Versions: Any
Requirements: N/A
Related Issues: Needs merged before:

@APickledWalrus APickledWalrus added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Aug 29, 2022
@AyhamAl-Ali
Copy link
Member

AyhamAl-Ali commented Aug 30, 2022

Noice PR ⚡

1- I don't know if any addon is using such system yet so IMO we can decide this later when we get more feedback on it.
2- That's good IMO, a backup is never a bad choice.

However, I would like this to have an option (in config.sk) so that users can choose to toggle auto update lang files in case they want to manually update with their custom lang files

@APickledWalrus
Copy link
Member Author

However, I would like this to have an option (in config.sk) so that users can choose to toggle auto update lang files in case they want to manually update with their custom lang files

That could be useful, however outdated lang files may result in console errors (as reported for Structure API, see https://discord.com/channels/988998880794402856/1012003185302450206/1013589722586689588 - testing guild).

This is why I opted for backups, as it ensures lang files will be up to date (but also preserves a user's work if they care to update it)

@AyhamAl-Ali
Copy link
Member

The choice relies on whether it's preferred to

1- Override the user lang files with the new lang files and force the users to adapt their custom lang files every update manually
2- Force the users to update their lang files (after having a similar error of Structure API) and adapt their changes once in a while (when a lang file changes in some update)

Based on the answer the default value of auto-update-lang-files should be set

@TheLimeGlass
Copy link
Contributor

TheLimeGlass commented Sep 14, 2022

Can this pull request also target the materials.json? Issue(s) stated here with error #4861

@APickledWalrus
Copy link
Member Author

Can this pull request also target the materials.json? Issue(s) stated here with error #4861

See #5105

@APickledWalrus
Copy link
Member Author

APickledWalrus commented Sep 21, 2022

The choice relies on whether it's preferred to

1- Override the user lang files with the new lang files and force the users to adapt their custom lang files every update manually 2- Force the users to update their lang files (after having a similar error of Structure API) and adapt their changes once in a while (when a lang file changes in some update)

Based on the answer the default value of auto-update-lang-files should be set

With the latest commit, it will only create backups if the lang file has been changed.
Unfortunately, I think we do need to force them to update. I don't think it's a good idea to add an opt out here because of the potential for errors (especially because the error message isn't always clear). We provide backups, so it wouldn't be the worse to convert over. We can also mention lang file changes in the update log :D

If allowing a bypass really is desirable, potentially we can find a way to provide a more meaningful error message :)

Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

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

Good. Maybe when we move on from Java 1.8 we can use try-with-resources.

Addresses TP's concerns
@APickledWalrus APickledWalrus merged commit a8df952 into SkriptLang:master Oct 3, 2022
@APickledWalrus APickledWalrus deleted the enhancement/lang-file-updates branch October 3, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants