diff --git a/lib/api/api.rb b/lib/api/api.rb index 045a0db184220e58e8ff3056ccbaebb1c11e6461..ad278b251c735a1e92844f925d070be9aec4251d 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -48,8 +48,8 @@ module API end before { header['X-Frame-Options'] = 'SAMEORIGIN' } - before { Gitlab::I18n.locale = current_user&.preferred_language } + # The locale is set to the current user's locale when `current_user` is loaded after { Gitlab::I18n.use_default_locale } rescue_from Gitlab::Access::AccessDeniedError do diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 234825480f23d7b22515553cdc5d88eb51baf690..99b8b62691f4280904779da0f779498b07ac9596 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -16,6 +16,8 @@ module API @current_user = initial_current_user + Gitlab::I18n.locale = @current_user&.preferred_language + sudo! @current_user