Download locales and translations without framework.
This commit is contained in:
parent
a8d321a21e
commit
f9c1040930
2 changed files with 48 additions and 10 deletions
|
@ -8,13 +8,4 @@ PATH=$(pwd)/bin:$(pwd)/vendor/bundle/bin:$PATH
|
|||
set -e
|
||||
|
||||
# download locales and translations to make a offline installation possible
|
||||
gem install bundle
|
||||
bundle install
|
||||
|
||||
rake db:migrate
|
||||
rake db:seed
|
||||
|
||||
rails r 'Locale.fetch'
|
||||
rails r 'Translation.fetch'
|
||||
|
||||
rm -rf tmp/cache*
|
||||
contrib/packager.io/fetch_locales.rb
|
||||
|
|
47
contrib/packager.io/fetch_locales.rb
Executable file
47
contrib/packager.io/fetch_locales.rb
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env ruby
|
||||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rubygems'
|
||||
require 'uri'
|
||||
require 'net/http'
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
|
||||
url_locales = 'https://i18n.zammad.com/api/v1/locales'
|
||||
url_translations = 'https://i18n.zammad.com/api/v1/translations/'
|
||||
|
||||
file_locales = 'config/locales.yml'
|
||||
directory_translations = 'config/translations'
|
||||
|
||||
# download locales
|
||||
uri = URI.parse(url_locales)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
response = http.request(request)
|
||||
data = JSON.parse(response.body)
|
||||
|
||||
puts "Writing #{file_locales}..."
|
||||
File.open(file_locales, 'w') do |out|
|
||||
YAML.dump(data, out)
|
||||
end
|
||||
|
||||
# download translations
|
||||
if !File.directory?(directory_translations)
|
||||
Dir.mkdir(directory_translations, 0o755)
|
||||
end
|
||||
data.each { |locale|
|
||||
url = "#{url_translations}#{locale['locale']}.yml"
|
||||
uri = URI.parse(url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
response = http.request(request)
|
||||
data = JSON.parse(response.body)
|
||||
file = "#{directory_translations}/#{locale['locale']}.yml"
|
||||
puts "Writing #{file}..."
|
||||
File.open(file, 'w') do |out|
|
||||
YAML.dump(data, out)
|
||||
end
|
||||
}
|
||||
puts 'done'
|
Loading…
Reference in a new issue