Skip to content

Conversation

@ducconit
Copy link

This Pull Request updates the goi18n extract command to be more flexible in identifying the source of messages to be extracted. Instead of hardcoding the check to the library's original package, developers can now configure the tool to scan their own structs or wrapper packages.

Key Changes: Added 2 new optional flags to the extract command:

  1. -i18nPackage (string): The import path of the package containing the message definitions.
    Default: github.com/nicksnyder/go-i18n/v2/i18n
  2. -i18nTypes (string): A comma-separated list of struct/type names to scan for message extraction.
    Default: Message,LocalizeConfig

Purpose:

  • Allows developers to extend or wrap the Message struct for their specific needs (e.g., adding validation, extra fields) while still leveraging the existing extract command.
  • Ensures backward compatibility: If these flags are not provided, the extract command behaves exactly as before, requiring no changes to existing codebases.

Example Usage:

# Extract from the default package (same as before)
goi18n extract

# Extract from a custom package and custom types
goi18n extract -i18nPackage "github.com/my-org/my-lib/i18n" -i18nTypes "CustomMessage,CustomConfig" .

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