Help me to merge old transladed file and new one


(Admir Hodzic) #1

Once upon I have translated client.yml and server files.
That was in early versions of Discourse. Unfortunately I did never have enough knowledge to git put that files to SVN.
Today discourse translation is Transifex and I did joined translation team for Bosnian language.

Now when I download for_translation_discourse-org_clientenyml_bs_BA I have headache to merge my old translated file to new One I did try whit COmpare plugin using NotePad++ but my old client file have 1364 lines.

Is there an easy way to I my old translated file (client.yml and server.yml) apply to actual ones which is current. So we can continue with translation


(Kai) #2

I’ve just written a Ruby script that merges two locale files and writes the result into a new file.

require 'yaml'
require 'active_support/core_ext/hash/deep_merge'

theirs = YAML.load_file('./locales/theirs/client.en.yml')['en']
mine   = YAML.load_file('./locales/mine/client.de.yml')['de']

yml = YAML.dump({ 'de' => theirs.deep_merge(mine)}, line_width: -1)
File.open('./locales/merged/client.de.yml', 'w') {|f| f.write(yml) }

The result contains all key/value pairs of client.en.yml. Values in client.de.yml overwrite the corresponding values in client.en.yml.

It’s not finished yet. When I fully tested it I’m going to put it on Github.


(Kai) #3

By the way my script is for custom translations only. You still need to find a good way to move your translations into Transifex.


(Admir Hodzic) #4

I think that I can simply uplado translated file, Since I can download file for translation I hope that I can also uplaod same file back to transferix.

My I please you to post link when you scrip be ready to use on GitHub thanx in advanced


(Kai) #5

Here’s a Raketask:

https://gist.github.com/kschaper/c202198c0f96362c0a3b

Please test locally first. The task overwrites existing files located in config/locales/. And please consider this script as beta software.


(Neil Lalonde) #6

Can you send a pull request according to these instructions? Then I can push all the files to Transifex for you.


(Kai) #7

I just added an explanation on how to use the Rake task.