Skip to content

Instantly share code, notes, and snippets.

@edouard
Last active March 6, 2019 14:23
Show Gist options
  • Save edouard/093025ce172d266cc74fa7ab22349878 to your computer and use it in GitHub Desktop.
Save edouard/093025ce172d266cc74fa7ab22349878 to your computer and use it in GitHub Desktop.
Converts a language file from one format to another using Ruby and the WebTranslateIt converter http://converter.webtranslateit.com
# Converts a language file from one format to another using the WebTranslateIt converter
# http://converter.webtranslateit.com
# A PHP version can be found here: https://gist.github.com/edouard/55a05bc4842da12f5074ab8286e77506
# gem install 'multipart-post'
require 'net/http/post/multipart'
converter = "Yml"
path = "path/to/your/file.resx"
url = URI.parse("http://converter.webtranslateit.com/converter")
File.open(path) do |file|
req = Net::HTTP::Post::Multipart.new url.path, "file" => UploadIO.new(file, "plain/text", file.path), "convert_to" => converter
res = Net::HTTP.start(url.host, url.port) do |http|
response = http.request(req)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment