Skip to content

Spreak gotext translator#8

Merged
debugger84 merged 2 commits intomainfrom
feature/gotext-translator
Jul 15, 2025
Merged

Spreak gotext translator#8
debugger84 merged 2 commits intomainfrom
feature/gotext-translator

Conversation

@debugger84
Copy link
Contributor

No description provided.

@debugger84 debugger84 requested a review from Copilot July 15, 2025 08:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Integrates the vorlif/spreak library as a replacement for golang.org/x/text to power translations across the service. Key changes include wiring up a spreak Bundle and Localizer via FX, updating middleware and context to use the new localizer, and extending error types to capture and localize hint arguments.

  • Introduce spreak.Bundle and spreak.Localizer in place of x/text printers
  • Revamp the FX module to load .po files and provide translation bundles
  • Migrate all context, middleware, error wrappers, and auth errors to use spreak APIs

Reviewed Changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
translation/translator.go Swapped x/text printer for spreak Localizer and bundle
translation/module.go Updated FX module to provide spreak.Bundle with locale files
translation/middleware.go Middleware now injects spreak.Localizer into request context
translation/install/translation.mk Added make target for xspreak extraction
translation/install/locales.go Provided embed FS group provider for locales
translation/error_wrapper_test.go Tests for storing and retrieving hint args in errors
translation/error_wrapper.go Wrapped errors to include JSON-encoded translation args
translation/error_processor_test.go Tests LocalizeErrorHint error processor functionality
translation/error_processor.go Error processor for localizing error hints with spreak
translation/context.go Replaced translators with Localizer in context
module/module.go Added Option pattern for Module customization
http/input.go Updated input handler to use Localizer for validation errors
http/errhttp/error_processor.go Changed ErrorPipeline to ordered map with ranks
graphql/server.go Refactored error presenter to use pipeline.Process
go.mod Bumped dependencies, added spreak
examples/blog/go.mod Updated indirect x/text and x/sync versions
errors/hint.go Changed error hint API to use localize.Singular
errors/erruser/error.go Updated user error creation to accept localize.Singular
errors/errsys/error.go Updated system error creation to accept localize.Singular
errors/error.go Removed old Message function stub
auth/module.go Integrated locales FS provider into auth module
auth/locales/uk-UA/auth.po Added Ukrainian translations for auth messages
auth/locales/locales.go Provided embed FS group for auth translation domain
auth/locales/auth.pot Added POT template for auth translations
auth/auth.go Annotated auth errors with translation domain and locales
Makefile Added translation-extract target for auth package
Comments suppressed due to low confidence (4)

translation/translator.go:36

  • [nitpick] The function name E is not descriptive. Consider renaming it to something like MarkForExtraction or ExtractMsgID so its purpose is clearer.
func E(txt localize.Singular) string {

translation/module.go:42

  • Building a slice of interface{} and passing it to spreak.WithLanguage(tags...) will not compile. Change the slice type to []language.Tag so you can spread it directly into the variadic function.
				tags := make([]interface{}, 0, len(cfg.Locales))

auth/auth.go:20

  • The erruser.New signature now expects a localize.Singular hint, not a plain string. Wrap literal hints in localize.Singular(...) to match the new API.
	erruser.New("invalid access token", "Please provide a valid access token"),

errors/errsys/error.go:10

  • Calls to errsys.New (e.g., in HideInternalError) still pass plain strings for the hint parameter. Update those calls to convert strings into localize.Singular.
func New(code string, hint localize.Singular) error {

@debugger84 debugger84 merged commit 9b24319 into main Jul 15, 2025
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