maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
140 stars 148 forks source link

Merging translations? #20

Closed alcarola closed 12 years ago

alcarola commented 12 years ago

Just a quick question. Is there a tool that can be used to merge two translation files of Stack? I would like to merge two translations that have partially the same strings. Alternatively, if I have to merge them by hand, is there a simple way to check which strings are present in both files? I use Linux and Mac os x.

ghost commented 12 years ago

Git itself has good tools for comparing two files and performing merges. They have their own man pages, man git diff and man git merge. These guides may be useful:

I guess the drawback is that git diff is designed to compare commits and git merge is designed to compare branches.

I think there is a linux command diff which is specifically designed to compare two files.

sangwinc commented 12 years ago

Thanks for commenting on this Ben.

alcarola commented 12 years ago

Thanks again for your responses!

Indeed Linux has diff (or xxdiff for graphical representations), but it works well only when comparing files that are identical almost everywhere. On files that differ a lot, it gets very confused. It turned out that the linux sort command was very useful for this, and I added a tiny linux script to do the merging modulo resolving the conflicting doubles. I don't know if you want the script in the source code tree or not. Just delete or move it as you wish.

Also, almost all of STACK is now translated to Swedish, apart from the help texts and some strings that were too technical for me to understand. Also, I don't know how to translate "CAS" into Swedish, but I will discuss that with the other Finland-Swedish Moodle translators. Therefore, I added myself to the translation credits. You may remove me if you don't want me there. :)

Also, a question. The id and text of the following string match quite poorly. Is it supposed to be like this? $string['ATSysEquiv_SA_system_overdetermined'] = 'The entries in red below are those that are incorrect. {$a->m0} ';

Mikael

ghost commented 12 years ago

That's great news.

Last night I put together a small script myself in case you had any issues. I've not tested it though.

alcarola commented 12 years ago

I'll try your script if I screw up my translations again. :) I'm not so fluent in PHP that I could have done that myself.

It's certainly not much fun to resolve the duplicates by hand, and if the duplicates are indeed duplicates in the sense that the strings are the same, then doing it automatically is desirable. In my case it was so that I had translated the same strings several times, and often one of the two translations was better, so I just discarded the worse of the two.

I don't know why the strings I had already translated disappeared, but for sure it was some instance of PEBKAC, because I've been translating Moodle at the same time, and also at the same time as I have been making some courses, so it's all been a bit of a mess. :)

ghost commented 12 years ago

The script only compares entire lines of each file, and the merge function probably concatenates the files. Far from useful, it needs a bit more work I suspect.

I've found grep handy when working in a directory of language files. For instance

grep error *

will show the lines which contain the word 'error'.

alcarola commented 12 years ago

Indeed, and if you write grep -r error * then it goes recursively into subdirectories, very useful for locating strings in translations, specific pieces of code in source code etc. I used grep in the script i posted to separate the headers from the strings in a language file. If you want grep to ignore case, then you can use grep -ri error *. :)

ghost commented 12 years ago

On 15/06/2012 16:50, Mikael Kurula wrote:

Indeed, and if you write grep -r error * then it goes recursively into subdirectories, very useful for locating strings in translations, specific pieces of code in source code etc. I used grep in the script i posted to separate the headers from the strings in a language file. If you want grep to ignore case, then you can use grep -ri error *. :)


Reply to this email directly or view it on GitHub: https://github.com/sangwinc/moodle-qtype_stack/issues/20#issuecomment-6359844

Thanks, that's a nice script.

timhunt commented 12 years ago

Did you get your problem sorted? Can we close this issue now?

alcarola commented 12 years ago

Yes, it's clear, thanks a lot for fixing everything again! I'll update my remotes and look forward to testing the quiz scoring out. I have only one week left in the Netherlands before moving back to Finland, so I'm very busy here, but I will get around to posting the other, mostly very minor, things that have come to my mind while working with Stack. For now, have a nice weekend! :)