Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make locale Makefile fully dynamic #38

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# make tx-update - download and merge translations from Transifex
# make clean - clean everything
#
DOMAIN = foreman_plugin_template
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative:

Suggested change
DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
DOMAIN = $(shell basename -s .gemspec ../*gemspec)

There may even be some fancy logic in Make itself.

@evgeni thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this breaks on foreman-tasks where the domain is foreman_tasks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are smarter ways to do basename in Make I think, but we really should not break tasks (which has that weird naming, but here we are).

The Ruby line seems reasonable to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is that the filename also matches the gem name so it shouldn't be a difference. In foreman-tasks it's also foreman-tasks.gemspec so there it wouldn't be a difference: both would be wrong. It'd be so much better if we renamed the gem to foreman_tasks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I don't have good experience with renaming gems so I'd like to avoid it if possible. Could we rename the domain instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you can't do that since - is not a valid character. It will fail here. I also don't know if the domain is used somewhere else.

Note that renaming the gem would also make it follow our other conventions and we don't need to special case it everywhere. Things like https://github.com/theforeman/puppet-foreman/blob/56404b20402960ff32ec983ce06c7c67517e2ce1/manifests/plugin/tasks.pp#L18 could be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare plugin_apipie to gettext.

I think the question is whether we want to support a dash at all. I think foreman-tasks is the only exception so I'm leaning to fixing the exception rather than allowing everything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened https://projects.theforeman.org/issues/35813 to track the foreman-tasks rename.

VERSION = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).version')
POTFILE = $(DOMAIN).pot
MOFILE = $(DOMAIN).mo
POFILES = $(shell find . -name '$(DOMAIN).po')
Expand Down