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

i18n - pulling from tx #611

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ file_filter = locale/<lang>/foreman_discovery.edit.po
source_file = locale/foreman_discovery.pot
source_lang = en
type = PO
minimum_perc = 0
minimum_perc = 50
resource_name = foreman_discovery
29 changes: 8 additions & 21 deletions locale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
# make tx-update - download and merge translations from Transifex
# make clean - clean everything
#
DOMAIN = foreman_discovery
VERSION = $(shell git describe --abbrev=0 --tags)
DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
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')
MOFILES = $(patsubst %.po,%.mo,$(POFILES))
POXFILES = $(patsubst %.po,%.pox,$(POFILES))
EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
JSFILES = $(shell find ../app/assets/javascripts/*/locale -name '$(DOMAIN).js')

%.mo: %.po
mkdir -p $(shell dirname $@)/LC_MESSAGES
msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
touch $(shell dirname $@)/LC_MESSAGES/$(MOFILE)
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 seen that this can be useful. msgfmt doesn't change the file (and keep the timestamp if the content is the same). That means the .po file can be newer than the .mo file.

Can be a good change to https://github.com/theforeman/foreman_plugin_template/blob/master/locale/Makefile and let other repos also benefit from it.


# Generate MO files from PO files
all-mo: $(MOFILES)
Expand All @@ -43,34 +43,21 @@ uniq-po:
done

tx-pull: $(EDITFILES)
tx pull -f
cd .. && tx pull -f --all
for f in $(EDITFILES) ; do \
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
done

tx-update: tx-pull
@echo
@echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
@echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation
@echo then run rake plugin:po_to_json[$(DOMAIN)] from the Foreman installation
@echo then run make -C locale mo-files to finish
@echo

mo-files: $(MOFILES)
git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES
git commit -m "i18n - pulling from tx"
@echo
@echo Changes commited!
@echo

# Workaround when rake task fails (https://github.com/ruby/rake/pull/182)
extract:
rxgettext \
--sort-output \
--sort-by-msgid \
--no-wrap \
--no-location \
-o ${DOMAIN}.pot \
--package-name=${DOMAIN} \
--package-version="${VERSION}" \
--msgid-bugs-address=foreman-dev@googlegroups.com \
--copyright-holder="Foreman developers" \
--copyright-year=$(shell date +%Y) \
$(shell find ../app -type f -name \*.rb -o -name \*.erb)
14 changes: 7 additions & 7 deletions locale/foreman_discovery.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: foreman_discovery 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-05 16:26+0200\n"
"PO-Revision-Date: 2023-06-05 16:26+0200\n"
"POT-Creation-Date: 2023-11-28 22:34+0100\n"
"PO-Revision-Date: 2023-11-28 22:34+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
Expand Down Expand Up @@ -311,27 +311,27 @@ msgstr ""
msgid "Discovered hosts are provisioning now"
msgstr ""

#: ../app/controllers/discovered_hosts_controller.rb:280
#: ../app/controllers/discovered_hosts_controller.rb:284
msgid ""
"Discovered host reported from unknown subnet, communication will not be proxie"
"d."
msgstr ""

#: ../app/controllers/discovered_hosts_controller.rb:285
#: ../app/controllers/discovered_hosts_controller.rb:289
msgid ""
"Discovered hosts reported from unknown subnet are %s, communication will not b"
"e proxied."
msgstr ""

#: ../app/controllers/discovered_hosts_controller.rb:299
#: ../app/controllers/discovered_hosts_controller.rb:303
msgid "No hosts were found with that id or name"
msgstr ""

#: ../app/controllers/discovered_hosts_controller.rb:303
#: ../app/controllers/discovered_hosts_controller.rb:307
msgid "No hosts selected"
msgstr ""

#: ../app/controllers/discovered_hosts_controller.rb:309
#: ../app/controllers/discovered_hosts_controller.rb:313
msgid "Something went wrong while selecting hosts - %s"
msgstr ""

Expand Down