Skip to content

Commit

Permalink
delete LangByTag
Browse files Browse the repository at this point in the history
  • Loading branch information
soneda-yuya committed Jan 12, 2025
1 parent e1dfba3 commit cc347cf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions server/internal/adapter/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ func User(ctx context.Context) *user.User {
return nil
}

func LangByTag(ctx context.Context, lang *language.Tag) string {
func Lang(ctx context.Context, lang *language.Tag) string {
if lang != nil && !lang.IsRoot() {
return lang.String()
}
return Lang(ctx)
}

func Lang(ctx context.Context) string {
if v := ctx.Value(contextLang); v != nil {
if lang, ok := v.(string); ok {
if lang == "" {
Expand Down
2 changes: 1 addition & 1 deletion server/internal/adapter/gql/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getUser(ctx context.Context) *user.User {
}

func getLang(ctx context.Context, lang *language.Tag) string {
return adapter.LangByTag(ctx, lang)
return adapter.Lang(ctx, lang)
}

func getOperator(ctx context.Context) *usecase.Operator {
Expand Down
2 changes: 1 addition & 1 deletion server/internal/app/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GraphqlAPI(conf config.GraphQLConfig, dev bool) echo.HandlerFunc {
func customErrorPresenter(ctx context.Context, e error, devMode bool) *gqlerror.Error {
var graphqlErr *gqlerror.Error
var appErr *apperror.AppError
lang := adapter.Lang(ctx)
lang := adapter.Lang(ctx, nil)

// Handle application-specific errors
systemError := ""
Expand Down
2 changes: 1 addition & 1 deletion server/internal/app/lang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestAttachLanguageMiddleware(t *testing.T) {

e.GET("/", func(c echo.Context) error {
// get lang from context
lang := adapter.Lang(c.Request().Context())
lang := adapter.Lang(c.Request().Context(), nil)
// include lang in response
return c.String(http.StatusOK, lang)
})
Expand Down

0 comments on commit cc347cf

Please sign in to comment.