Actions
Feature #36117
openTracker #36116: Translation effort
Provide a rake task to compile .mo files from .po in a generic way
Status:
New
Priority:
Normal
Assignee:
-
Category:
Rake tasks
Target version:
-
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.
Updated by Ewoud Kohl van Wijngaarden almost 2 years ago
- Blocks Bug #35789: Compile plugin .mo files during package build added
Updated by Ewoud Kohl van Wijngaarden almost 2 years ago
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
Actions