Skip to content

Instantly share code, notes, and snippets.

View edouard's full-sized avatar

Edouard Brière edouard

View GitHub Profile
@edouard
edouard / en.yml
Created November 11, 2022 15:27
WebTranslateIt YAML update
en:
activerecord:
errors:
full_messages:
format: "%{attribute} %{message}"
messages:
accepted: must be accepted
blank: can't be blank
confirmation: doesn't match confirmation
empty: can't be empty
@edouard
edouard / gist:b41c207ee28e5f6fd6e7fe8fbdb82cf0
Created November 9, 2022 09:40
Using the converter.webtranslateit.com using CURL
curl -v -F convert_to=Strings -F file=@en.json https:/converter.webtranslateit.com/converter
// At the end of your layouts/application.html.haml file, convert the YAML Hash to a JS Hash:
:javascript
window.I18n = #{sanitize(js_translations.to_json)}
@edouard
edouard / convert.php
Last active March 6, 2019 14:23
Converts a language file from one format to another using PHP and the WebTranslateIt converter http://converter.webtranslateit.com
<?php
// Converts a language file from one format to another using the WebTranslateIt converter
// http://converter.webtranslateit.com
// A ruby version can be found here: https://gist.github.com/edouard/093025ce172d266cc74fa7ab22349878
// initialize the curl request
$request = curl_init("http:/converter.webtranslateit.com/converter");
// send a file
curl_setopt($request, CURLOPT_POST, true);
@edouard
edouard / script.rb
Created December 27, 2017 09:11
Create a translation on WebTranslateIt using the create Translation endpoint
require "net/http"
require "json"
http = Net::HTTP.new("webtranslateit.com", 443)
http.use_ssl = true
request = Net::HTTP::Post.new("/api/projects/proj_pvt_wL2h87YRMpKLXa8OYdnXAw/strings/15452121/locales/en/translations", {"Content-Type" => "application/json" })
request.body = { "text" => { "one" => "one text", "other" => "other text"} }.to_json
response = http.request(request)
@edouard
edouard / script.rb
Created December 26, 2017 13:28
Create a plural segment on WebTranslateIt using the API
require "net/http"
require "json"
http = Net::HTTP.new("webtranslateit.com", 443)
http.use_ssl = true
request = Net::HTTP::Post.new("/api/projects/:api_key/strings", {"Content-Type" => "application/json" })
request.body = { "key" => "test_plural", "plural" => true, "translations" => [ { "locale" => "en", "text" => { "one" => "dksjdksjd", "other" => "dksjdskdj"} }] }.to_json
response = http.request(request)
@edouard
edouard / webtranslateit_converter.rb
Last active March 6, 2019 14:23
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"
# before using: gem install web_translate_it
require "web_translate_it"
api_key = "your_api_key"
WebTranslateIt::Connection.new(api_key) do
WebTranslateIt::String.find_all({ key: "key_name" }).each do |string|
puts "key: #{string.key}"
puts "FR value: #{string.translation_for("fr")}"
end
@edouard
edouard / messages.json_null_to_empty-string.ps1
Created May 24, 2014 09:57
JSON file "null" to empty string converter
###############################################################################
# JSON file "null" to empty string converter
# For use with WebTranslateIt and Google Chrome extension i18n files
# -WTI will spit out unproofread segments as "null" (without quotes), but
# Chrome needs missing segments to be empty strings
# -Replace "null" with an empty string so that the target files can still be
# properly marked as unproofread in the WTI UI
@edouard
edouard / test.yml
Last active December 11, 2015 21:58
en:
country:
es: Spain
no: "Norway (doesn’t work)"
"no": Norway