translations_controller.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class TranslationsController < ApplicationController
  3. prepend_before_action :authentication_check, except: [:lang]
  4. # GET /translations/lang/:locale
  5. def lang
  6. render json: Translation.lang(params[:locale])
  7. end
  8. # PUT /translations/push
  9. def push
  10. permission_check('admin.translation')
  11. start = Time.zone.now
  12. Translation.push(params[:locale])
  13. if start > Time.zone.now - 4.seconds
  14. sleep 3
  15. end
  16. render json: { message: 'ok' }, status: :ok
  17. end
  18. # POST /translations/sync/:locale
  19. def sync
  20. permission_check('admin.translation')
  21. Translation.load(params[:locale])
  22. render json: { message: 'ok' }, status: :ok
  23. end
  24. # POST /translations/reset
  25. def reset
  26. permission_check('admin.translation')
  27. Translation.reset(params[:locale])
  28. render json: { message: 'ok' }, status: :ok
  29. end
  30. # GET /translations/admin/lang/:locale
  31. def admin
  32. permission_check('admin.translation')
  33. render json: Translation.lang(params[:locale], true)
  34. end
  35. # GET /translations
  36. def index
  37. permission_check('admin.translation')
  38. model_index_render(Translation, params)
  39. end
  40. # GET /translations/1
  41. def show
  42. permission_check('admin.translation')
  43. model_show_render(Translation, params)
  44. end
  45. # POST /translations
  46. def create
  47. permission_check('admin.translation')
  48. model_create_render(Translation, params)
  49. end
  50. # PUT /translations/1
  51. def update
  52. permission_check('admin.translation')
  53. model_update_render(Translation, params)
  54. end
  55. # DELETE /translations/1
  56. def destroy
  57. permission_check('admin.translation')
  58. model_destroy_render(Translation, params)
  59. end
  60. end