Skip to content

Instantly share code, notes, and snippets.

@koduki
Created August 2, 2008 18:04
Show Gist options
  • Save koduki/3751 to your computer and use it in GitHub Desktop.
Save koduki/3751 to your computer and use it in GitHub Desktop.
#!/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