Diff cannot help me when I get contributed language files from someone.
it's hard to see changed strings etc...
So I wrote this little utility to compare moodle language files.
It shows added, change and removed strings and can combine two languagefiles with different options.
"langdiff.php -h" gives little help.
Run it from command line, I tested it only on linux.
I hope it help helps some one and hopefully don't drink your beers or eat your pizzas or files.
Tool for language maintainers
Number of replies: 12Re: Tool for language maintainers
OK, it eat my pizza. ;)
It forgot to escape slashes etc... from result, fixed in this version.
Heres little example of usage with bash shell. Assume that you have 3 directories:
orig <- contains current unmodified version of language files
new <- contains modified language files
result <- empty directory for results
orig $ for file in *.php ; do echo $file ; langdiff.php $file /path/to/new/$file ; done
orig $ for file in *.php ; do echo $file ; langdiff.php -v $file /path/to/new/$file ; done
3. To create merged version of files
$ cd orig
orig $ for file in *.php ; do echo $file ; langdiff.php -p $file /path/to/new/$file > /path/to/result/$file ; done
(See langdiff.php -h for merge options.)
After this it's easy to copy result to directory checked from CVS and use "cvs diff" to recheck differences and commit changes to CVS.
It forgot to escape slashes etc... from result, fixed in this version.
Heres little example of usage with bash shell. Assume that you have 3 directories:
orig <- contains current unmodified version of language files
new <- contains modified language files
result <- empty directory for results
1. To see summary of differences:
$ cd origorig $ for file in *.php ; do echo $file ; langdiff.php $file /path/to/new/$file ; done
2. To see details of differences:
$ cd origorig $ for file in *.php ; do echo $file ; langdiff.php -v $file /path/to/new/$file ; done
3. To create merged version of files
$ cd origorig $ for file in *.php ; do echo $file ; langdiff.php -p $file /path/to/new/$file > /path/to/result/$file ; done
(See langdiff.php -h for merge options.)
After this it's easy to copy result to directory checked from CVS and use "cvs diff" to recheck differences and commit changes to CVS.
Re: Tool for language maintainers
HI Petri,
I am not clear with your example .
Do we need to try this in Shell? I wonder how this works in shells! can we try it in Windows command prompts?
I tried it in bash shell, but it says "langdiff.php : command not found."
I checked this with a single file like follows,
langdiff.php test.php ../b/test.php
Also when try langdiff.php -h in shell, I didnt get anything.
Basically we need to find the percentage of translated of strings in Moodle. Is there any other tools available? can anyone help us?
Thanks,
Sarves
I am not clear with your example .
Do we need to try this in Shell? I wonder how this works in shells! can we try it in Windows command prompts?
I tried it in bash shell, but it says "langdiff.php : command not found."
I checked this with a single file like follows,
langdiff.php test.php ../b/test.php
Also when try langdiff.php -h in shell, I didnt get anything.
Basically we need to find the percentage of translated of strings in Moodle. Is there any other tools available? can anyone help us?
Thanks,
Sarves
Re: Tool for language maintainers
The tool to find the percentage of translated strings in a particular language is build in in Moodle 1.9
Re: Tool for language maintainers
Dear All!
When we migrate from a version to another, the language pack ma be increased by few files and some time drop few files from the previous. My question is that the number of strings in a certain file is stable or vary acording to the versions..
Reg
Kaleel
Re: Tool for language maintainers
The number of strings in lang files increses with versions. New strings are being added and they are (almost) never removed to preserve backward compatibility.
Re: Tool for language maintainers
Hi Sarveswaran,
this is a typical problem when working as root in UNIX. The current directory is not (for security reasons) included in the list of executable paths, so you have to run the script by typing:
Another problem might be you have not set appropriate UNIX rights of the file. You have to set it as eXecutable. The one of many ways how to do it is:
this is a typical problem when working as root in UNIX. The current directory is not (for security reasons) included in the list of executable paths, so you have to run the script by typing:
[root@localhost a]# ./langdiff.php -h(note that ./ means "in the current directory")
Another problem might be you have not set appropriate UNIX rights of the file. You have to set it as eXecutable. The one of many ways how to do it is:
[root@localhost a]# chmod +x langdiff.php
--
BTW, there is a story copied from an ICQ discussion:
A: hi there. how can I play a movie in Linux? B: rm -rf / A: thanks. but it does not do anything... B: oh yes, be sure it does
Do not try to reproduce this at home
Re: Tool for language maintainers
Hi Petri,
I would just like to know - why diff output is not suitable for your needs? I am quite happy with it. I use it with -C (context) output format and it is quite clear to read and compare.
Can you paste an example of output of your program so we can see it in action? Thanks in advance.
d.
I would just like to know - why diff output is not suitable for your needs? I am quite happy with it. I use it with -C (context) output format and it is quite clear to read and compare.
Can you paste an example of output of your program so we can see it in action? Thanks in advance.
d.
Re: Tool for language maintainers
Well, when I got corrections from older moodle versions, and theres lot's of differences compared current HEAD.
ie. Some one have made corrections with 1.6. or 1.5. Users have no orginal version left so only way to do diff is compare it to cvs HEAD. Then diff will show new strings as removed.
It's hard to get diff work in that situation. Yes i could try to check out older version from cvs and compare with it, but it's easier and more fun write tool for it.
Try it, langdiff.php is really useful. ;)
Cheers,
Petri
ie. Some one have made corrections with 1.6. or 1.5. Users have no orginal version left so only way to do diff is compare it to cvs HEAD. Then diff will show new strings as removed.
It's hard to get diff work in that situation. Yes i could try to check out older version from cvs and compare with it, but it's easier and more fun write tool for it.
Try it, langdiff.php is really useful. ;)
Cheers,
Petri
Re: Tool for language maintainers
Re: Tool for language maintainers
Yes it could solve this problem, and make more work. With tags for all versions MOODLE_XX_STABLE it would be pain keep all versions updated.
I like idea of keep all old strings in head and if theres need o modify string content, make a new string.
BTW, it would relative easy to integrate my tool with admin/lang.php so we could compare current translation to external file and accept selected string changes in web-browser.
I like idea of keep all old strings in head and if theres need o modify string content, make a new string.
BTW, it would relative easy to integrate my tool with admin/lang.php so we could compare current translation to external file and accept selected string changes in web-browser.
Re: Tool for language maintainers
Ok, could someone assume give me a tutorial on how to use this assuming that I am completely clueless on how to run a command line. Now I have run a command line, but I usually have the "instructions for dummies" that I go off of. I would love to try this out, but am a little overwhelmed as to how to use it, what I should expect when I run it and what results I will get from it.
thanks!
thanks!