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

Generate lang files at build time #174

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MattSturgeon
Copy link
Member

@MattSturgeon MattSturgeon commented Feb 7, 2024

  • Refactor :metadata into a more general :data project
  • Introduce a custom gradle task that can "build" lang files
  • Move most VariantTooltip logic to the gradle task
  • Move mod description to lang files
  • Use the built description in mod metadata
  • Reformat lang files as .properties (not planned)
  • Split lang files into main & config (low priority?)
  • Allow defining per-file key prefix/suffix or json "flattening" (not planned)
  • Fabric support (using ModMenu's documented API)
  • Forge support (depends on Support mod info translations in Mod Menu neoforged/NeoForge#639)
  • Unit tests for LangTask
  • Unit tests for the LangProcessor implementations

Fixes #172

@MattSturgeon MattSturgeon added enhancement New feature or request i18n Internationalization: languages & translation labels Feb 7, 2024
@MattSturgeon MattSturgeon self-assigned this Feb 7, 2024
In preparation for it also handling other data
@MattSturgeon MattSturgeon marked this pull request as ready for review February 8, 2024 12:05
@MattSturgeon

This comment was marked as outdated.

MattSturgeon

This comment was marked as outdated.

Modularise the tasks in preparation for adding more, and do some general cleanup:

- Drop special jar names
- Force ide to recognise `platform` & `variant` as `String`s
- Split metadata & jar tasks
Copy link
Member Author

@MattSturgeon MattSturgeon Feb 9, 2024

Choose a reason for hiding this comment

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

ModNameProcessor & ModDescriptionProcessor are implemented almost identically.

The only difference is how ModMenu's "summary" is handled, which assumes the summary should be the description without any variant-specific suffix.
We may prefer having separate long_description and short_description down the line?

There's probably a way to generalise them into a single implementation, but as I'm new to kotlin I'm not spending time designing that for the sake of two functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe some kinda factory or builder would help here?

- Move lang files from `:common` to `:data`
- Build them using a new `LangTask` Gradle task type 👀
- Update Crowdin config
- Removed Crowdin `languages_mapping` 😃

`LangTask` is used to build/process i18n lang files, allowing for more control over what is included and how.
Introduce `VariantTooltipProcessor`, which `LangTask`s use to process `VariantTooltip`s.

This allows the runtime implementation to be greatly simplified, it now only handles differences in line `count`.
Move name & description definition from `gradle.properties` to a lang file in `:data`.

Introduce `ModNameProcessor` & `ModDescriptionProcessor`, along with a new method `LangTask.getTranslation()` which can be used to get a specific translation after the task has finished running.

Make use of this in `:data` to get the name & description from the translations into the mod metadata file.

Fixes MinecraftFreecam#172
@MattSturgeon
Copy link
Member Author

Added some basic unit tests for the LangProcessor implementations & cleaned up LangTask a little.

@MattSturgeon
Copy link
Member Author

Dropped the forge mixin for now, hopefully we'll get a proper upstream solution.

@MattSturgeon
Copy link
Member Author

MattSturgeon commented Feb 25, 2024

Neoforge has added support in v2.4.179, using the following keys:

  • fml.menu.mods.info.displayname.freecam
  • fml.menu.mods.info.description.freecam

I've also been thinking about better ways to approach the transformer funcs and "variant" translations, at risk of making this even more over-engineered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request i18n Internationalization: languages & translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i18n: Support translating mod description
1 participant