translations_controller.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class TranslationsController < ApplicationController
  3. prepend_before_action -> { authentication_check && authorize! }, 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. start = Time.zone.now
  11. Translation.push(params[:locale])
  12. if start > Time.zone.now - 4.seconds
  13. sleep 3
  14. end
  15. render json: { message: 'ok' }, status: :ok
  16. end
  17. # POST /translations/sync/:locale
  18. def sync
  19. Translation.load(params[:locale])
  20. render json: { message: 'ok' }, status: :ok
  21. end
  22. # POST /translations/reset
  23. def reset
  24. Translation.reset(params[:locale])
  25. render json: { message: 'ok' }, status: :ok
  26. end
  27. # GET /translations/admin/lang/:locale
  28. def admin
  29. render json: Translation.lang(params[:locale], true)
  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. # POST /translations
  40. def create
  41. model_create_render(Translation, params)
  42. end
  43. # PUT /translations/1
  44. def update
  45. model_update_render(Translation, params)
  46. end
  47. # DELETE /translations/1
  48. def destroy
  49. model_destroy_render(Translation, params)
  50. end
  51. end