locale.rb 662 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Account::Locale < BaseMutation
  4. description 'Update the language of the currently logged in user'
  5. argument :locale, String, 'The locale to use, e.g. "de-de".'
  6. field :success, Boolean, null: false, description: 'Was the update successful?'
  7. def resolve(locale:)
  8. if !Locale.exists?(locale: locale, active: true)
  9. raise ActiveRecord::RecordNotFound, __('Locale could not be found.')
  10. end
  11. context.current_user.preferences['locale'] = locale
  12. context.current_user.save!
  13. { success: true }
  14. end
  15. end
  16. end