Feature #36117
open
Tracker #36116: Translation effort
Provide a rake task to compile .mo files from .po in a generic way
Added by Ewoud Kohl van Wijngaarden almost 2 years ago.
Updated almost 2 years ago.
Description
To make #35789 easier, a rake task should be provided to compile to .mo files for a plugin. So something like rake locale:compile[my_plugin].
It should generate a $LOCALE_DIR/$LANG/LC_MESSAGES/$DOMAIN.mo file for every $LOCALE_DIR/$LANG/$DOMAIN.po file.
Related issues
1 (1 open — 0 closed)
- Blocks Bug #35789: Compile plugin .mo files during package build added
Implementation in Rake:
# Convert locale/$LANG/LC_MESSAGES/$DOMAIN.mo to locale/$LANG/$DOMAIN.po
source_po_file = ->(mo) { File.join(File.dirname(File.dirname(mo)), "#{File.basename(mo, File.extname(mo))}.po") }
rule '.mo' => source_po_file do |t|
FileUtils.mkdir_p(File.dirname(t.name))
sh "msgfmt -o '#{t.name}' '#{t.source}'"
end
namespace :locale do
desc 'compile .mo files from .po files'
task :mo do
FileList["**/*.po"].each do |file|
next if file.end_with?('.edit.po')
domain = File.basename(file, File.extname(file))
mo_file = File.join(File.dirname(file), 'LC_MESSAGES', "#{domain}.mo")
Rake::Task[mo_file].invoke
end
end
end
Also available in: Atom
PDF