Class: LesliBabel::TranslationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_babel/translations_controller.rb

Instance Method Summary collapse

Instance Method Details

#cleanObject



87
88
89
# File 'app/controllers/lesli_babel/translations_controller.rb', line 87

def clean
    respond_with_successful()
end

#createObject

POST /translations



56
57
58
59
60
61
62
63
64
# File 'app/controllers/lesli_babel/translations_controller.rb', line 56

def create
    @translation = Translation.new(translation_params)

    if @translation.save
        redirect_to @translation, notice: "Translation was successfully created."
    else
        render :new
    end
end

#deployObject



91
92
93
94
95
96
# File 'app/controllers/lesli_babel/translations_controller.rb', line 91

def deploy
    #TranslationsService.clean
    DeployRailsService.new(current_user, query).build
    #TranslationsService.restart_server
    respond_with_successful
end

#destroyObject

DELETE /translations/1



76
77
78
79
# File 'app/controllers/lesli_babel/translations_controller.rb', line 76

def destroy
    @translation.destroy
    redirect_to translations_url, notice: "Translation was successfully destroyed."
end

#downloadObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'app/controllers/lesli_babel/translations_controller.rb', line 110

def download

    engine = params[:engine]
    platform = params[:platform]

    translations_result = TranslationsMiddlemanService.build(engine) if platform == "middleman"
    translations_result = TranslationsAndroidService.build(engine) if platform == "android"
    translations_result = TranslationsFlutterService.build(engine) if platform == "flutter"
    translations_result = TranslationsIosService.build(engine) if platform == "ios"
    translations_result = TranslationsJsService.build() if platform == "js"

    return respond_with_error if translations_result.blank?

    zip_file = "#{platform}-#{engine}-translations.zip"

    LC::System::IO.zip(zip_file, translations_result.payload)

    redirect_to "/tmp/#{zip_file}"

end

#editObject

GET /translations/1/edit



52
53
# File 'app/controllers/lesli_babel/translations_controller.rb', line 52

def edit
end

#indexObject

GET /translations



38
39
40
# File 'app/controllers/lesli_babel/translations_controller.rb', line 38

def index
    #@translations = Translation.all
end

#newObject

GET /translations/new



47
48
49
# File 'app/controllers/lesli_babel/translations_controller.rb', line 47

def new
    @translation = Translation.new
end

#optionsObject



81
82
83
84
85
# File 'app/controllers/lesli_babel/translations_controller.rb', line 81

def options
    respond_with_successful({
        locales_available: Lesli.config.locales
    })
end

#renovateObject



98
99
100
101
102
# File 'app/controllers/lesli_babel/translations_controller.rb', line 98

def renovate
    result = TranslationsSynchronizationService.remote_sync
    respond_with_successful if result.success?
    respond_with_error if not result.success?
end

#showObject

GET /translations/1



43
44
# File 'app/controllers/lesli_babel/translations_controller.rb', line 43

def show
end

#syncObject



104
105
106
107
108
# File 'app/controllers/lesli_babel/translations_controller.rb', line 104

def sync
    result = TranslationsSynchronizationService.remote_sync true
    respond_with_successful if result.success?
    respond_with_error if not result.success?
end

#updateObject

PATCH/PUT /translations/1



67
68
69
70
71
72
73
# File 'app/controllers/lesli_babel/translations_controller.rb', line 67

def update
    if @translation.update(translation_params)
        redirect_to @translation, notice: "Translation was successfully updated."
    else
        render :edit
    end
end