translations_controller.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class TranslationsController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!, except: [:lang]
  4. def lang
  5. render json: Translation.lang(params[:locale])
  6. end
  7. # GET /translations/customized
  8. def index_customized
  9. render json: Translation.customized.details, status: :ok
  10. end
  11. # GET /translations/search/:locale
  12. def search
  13. translations_search = Service::Translation::Search.new(locale: params[:locale], query: params[:query])
  14. render json: translations_search.execute, status: :ok
  15. end
  16. # POST /translations/upsert
  17. def upsert
  18. translations_upsert = Service::Translation::Upsert.new(locale: params[:locale], source: params[:source], target: params[:target])
  19. render json: translations_upsert.execute, status: :ok
  20. end
  21. # POST /translations/reset
  22. def reset
  23. Translation.reset(params[:locale])
  24. render json: { message: 'ok' }, status: :ok
  25. end
  26. # PUT /translations/reset/:id
  27. def reset_item
  28. translation = Translation.find(params[:id])
  29. render json: translation.reset, status: :ok
  30. end
  31. # GET /translations
  32. def index
  33. model_index_render(Translation, params)
  34. end
  35. # GET /translations/1
  36. def show
  37. model_show_render(Translation, params)
  38. end
  39. # PUT /translations/1
  40. def update
  41. model_update_render(Translation, params)
  42. end
  43. # DELETE /translations/1
  44. def destroy
  45. model_destroy_render(Translation, params)
  46. end
  47. end