-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
) | ||
|
||
var T goi18n.TranslateFunc | ||
var T i18n.TranslateFunc |
There was a problem hiding this comment.
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 == "" { |
There was a problem hiding this comment.
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.
Looks great to me. Passed all tests and tried a few more manual tests too and all good. Nice contrib :) |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
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
./bin/test