diff --git a/.gitignore b/.gitignore index c9fddd4..06ba05f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ Gemfile.local Gemfile.local.rb pkg .bundle + +# Locale files +locale/*/*.edit.po +locale/*/*.po.time_stamp diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..38b3fca --- /dev/null +++ b/.tx/config @@ -0,0 +1,9 @@ +[main] +host = https://app.transifex.com + +[o:foreman:p:foreman:r:hammer-cli-foreman-leapp] +file_filter = locale//hammer-cli-foreman-leapp.edit.po +source_file = locale/hammer-cli-foreman-leapp.pot +source_lang = en +type = PO +resource_name = hammer-cli-foreman-leapp diff --git a/Gemfile b/Gemfile index 7f4f5e9..1f4c45f 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,5 @@ source 'https://rubygems.org' gemspec + +gem 'gettext', '>= 3.1.3', '< 4.0.0' diff --git a/Rakefile b/Rakefile index d43a8db..32e73c2 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,8 @@ require 'rake/testtask' require 'bundler/gem_tasks' Bundler::GemHelper.install_tasks + +require "hammer_cli_foreman_leapp/version" +require "hammer_cli_foreman_leapp/i18n" +require "hammer_cli/i18n/find_task" +HammerCLI::I18n::FindTask.define(HammerCLIForemanLeapp::I18n::LocaleDomain.new, HammerCLIForemanLeapp.version.to_s) diff --git a/hammer_cli_foreman_leapp.gemspec b/hammer_cli_foreman_leapp.gemspec index 7c153b6..28b7c89 100644 --- a/hammer_cli_foreman_leapp.gemspec +++ b/hammer_cli_foreman_leapp.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.platform = Gem::Platform::RUBY spec.summary = 'Foreman Leapp plugin for Hammer CLI' - spec.files = Dir['{lib,config}/**/*', 'LICENSE', 'README*'] + spec.files = Dir['{lib,config}/**/*', 'LICENSE', 'README*'] + Dir["locale/**/*.{po,pot,mo}"] spec.require_paths = ['lib'] spec.test_files = Dir['{test}/**/*'] diff --git a/lib/hammer_cli_foreman_leapp.rb b/lib/hammer_cli_foreman_leapp.rb index df4351e..f2cda84 100644 --- a/lib/hammer_cli_foreman_leapp.rb +++ b/lib/hammer_cli_foreman_leapp.rb @@ -4,6 +4,7 @@ require 'hammer_cli_foreman' require 'hammer_cli_foreman_leapp/version' +require 'hammer_cli_foreman_admin/i18n' require 'hammer_cli_foreman_leapp/preupgrade_reports' module HammerCLIForemanLeapp diff --git a/lib/hammer_cli_foreman_leapp/i18n.rb b/lib/hammer_cli_foreman_leapp/i18n.rb new file mode 100644 index 0000000..baca2c5 --- /dev/null +++ b/lib/hammer_cli_foreman_leapp/i18n.rb @@ -0,0 +1,28 @@ +require 'hammer_cli/i18n' + +module HammerCLIForemanLeapp + module I18n + class LocaleDomain < HammerCLI::I18n::LocaleDomain + def translated_files + Dir.glob(File.join(File.dirname(__FILE__), '../**/*.rb')) + end + + def locale_dir + File.join(File.dirname(__FILE__), '../../locale') + end + + def domain_name + 'hammer-cli-foreman-leapp' + end + end + + class SystemLocaleDomain < LocaleDomain + def locale_dir + '/usr/share/locale' + end + end + end +end + +domain = [HammerCLIForemanLeapp::I18n::LocaleDomain.new, HammerCLIForemanLeapp::I18n::SystemLocaleDomain.new].find { |d| d.available? } +HammerCLI::I18n.add_domain(domain) if domain diff --git a/locale/Makefile b/locale/Makefile new file mode 100644 index 0000000..3618d81 --- /dev/null +++ b/locale/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for PO merging and MO generation. More info in the README. +# +# Run make help to list available targets +# +include $(shell bundle exec ruby -e 'require "hammer_cli"; puts HammerCLI::I18n.main_makefile') diff --git a/locale/en/hammer-cli-foreman-leapp.po b/locale/en/hammer-cli-foreman-leapp.po new file mode 100644 index 0000000..f0a14ab --- /dev/null +++ b/locale/en/hammer-cli-foreman-leapp.po @@ -0,0 +1,54 @@ +# English translations for hammer-cli-foreman-leapp package. +# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the hammer-cli-foreman-leapp package. +# FIRST AUTHOR , 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: hammer-cli-foreman-leapp 0.1.1\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-12 15:43+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: English\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=; plural=;\n" +"\n" + +msgid "Id" +msgstr "" + +msgid "Reported at" +msgstr "" + +msgid "Job Invocation Id" +msgstr "" + +msgid "Host Id" +msgstr "" + +msgid "Entries" +msgstr "" + +msgid "Host name" +msgstr "" + +msgid "Title" +msgstr "" + +msgid "Actor" +msgstr "" + +msgid "Audience" +msgstr "" + +msgid "Severity" +msgstr "" + +msgid "Tags" +msgstr "" + +msgid "Summary" +msgstr "" diff --git a/locale/hammer-cli-foreman-leapp.pot b/locale/hammer-cli-foreman-leapp.pot new file mode 100644 index 0000000..1bda46b --- /dev/null +++ b/locale/hammer-cli-foreman-leapp.pot @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the hammer-cli-foreman-leapp package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: hammer-cli-foreman-leapp 0.1.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-12 15:43+0000\n" +"PO-Revision-Date: 2023-07-12 15:43+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:9 +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:21 +msgid "Id" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:10 +msgid "Reported at" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:11 +msgid "Job Invocation Id" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:12 +msgid "Host Id" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:20 +msgid "Entries" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:22 +msgid "Host name" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:23 +msgid "Title" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:24 +msgid "Actor" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:25 +msgid "Audience" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:26 +msgid "Severity" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:27 +msgid "Tags" +msgstr "" + +#: ../lib/hammer_cli_foreman_leapp/preupgrade_reports.rb:28 +msgid "Summary" +msgstr ""