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

refactor: Updated go-i18n API to support v2 and v1 #99

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

Aerex
Copy link
Collaborator

@Aerex Aerex commented Jul 20, 2023

Context

There is a security vulnerability using version 1 of go-i18n so we need to update. However, the V2 API for go-i18n is significantly different from the older versions. To ensure that we don't break backwards compatibility, a wrapper was made around the V2 API using the V1.

Steps to Test

Run Unit Tests

Note: The unit tests for rewrite-package uses the go-i18n template to generate a i18n.go file for handling translations. This should sufficient to test the refactoring

  1. Run the command: ./bin/test
  2. Verify that all the tests pass

)

var T goi18n.TranslateFunc
var T i18n.TranslateFunc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Callout: To avoid disruption the API i18n.TranslateFunc method looks the same as the TranslateFunc from goi18n from version 1

localizer := go_i18n.NewLocalizer(bundle, DEFAULT_LOCALE)
tfunc := translate(localizer)
for _, s := range sources {
if s == "" {
Copy link
Collaborator Author

@Aerex Aerex Jul 20, 2023

Choose a reason for hiding this comment

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

Callout: If we can't determine the language source we will just skip it. I am open to other suggestions.

@maximilien
Copy link
Owner

Looks great to me. Passed all tests and tried a few more manual tests too and all good. Nice contrib :)

@maximilien
Copy link
Owner

/lgtm

@maximilien maximilien merged commit b191d10 into master Jul 21, 2023
5 checks passed
@maximilien maximilien self-assigned this Jul 21, 2023
Copy link
Owner

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/lgtm

@maximilien maximilien deleted the refactor/94-update-to-i18n-v2 branch July 21, 2023 22:29
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.

Refactor go-i18n API calls to support v2 using the v1 API
2 participants