Created
August 2, 2008 18:04
-
-
Save koduki/3751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
LOCALE_DIR = "/usr/share/locale/ja/" | |
LC_MESSAGES = LOCALE_DIR + "LC_MESSAGES/" | |
def mo2po files | |
files.each do |name| | |
puts name | |
system "msgunfmt #{LC_MESSAGES + name}.mo -o #{name}.po" | |
end | |
end | |
def po2mo files | |
files.each do |name| | |
puts name | |
system "msgfmt -c --statistics #{name}.po -o #{LC_MESSAGES + name}.mo" | |
end | |
end | |
def filelist ext | |
files = if(ARGV.size == 1) | |
`#{"ls -1 *.#{ext}"}`.split(/\n/) | |
else | |
ARGV[1, ARGV.size - 1] | |
end | |
files.map { |file| file[0, file.size-3] } | |
end | |
case ARGV[0] | |
when 'mo2po' | |
mo2po filelist("mo") | |
when 'po2mo' | |
po2mo filelist("po") | |
else | |
puts 'no such a command.' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment