forked from Katello/hammer-cli-csv
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plugins should support i18n. This commit adds the basics, but the eng…
…ineers need to start translating code
- Loading branch information
Showing
7 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'hammer_cli/i18n' | ||
|
||
module HammerCLICsv | ||
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_csv' | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
HammerCLI::I18n.add_domain(HammerCLICsv::I18n::LocaleDomain.new) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# Makefile for PO merging and MO generation. More info in the README. | ||
# | ||
# make all-mo (default) - generate MO files | ||
# make check - check translations using translate-tool | ||
# make tx-update - download and merge translations from Transifex | ||
# make clean - clean everything | ||
# | ||
DOMAIN = hammer_cli_csv | ||
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load("../hammer_cli_csv.gemspec");puts spec.version') | ||
POTFILE = $(DOMAIN).pot | ||
MOFILE = $(DOMAIN).mo | ||
POFILES = $(shell find . -name '*.po') | ||
MOFILES = $(patsubst %.po,%.mo,$(POFILES)) | ||
POXFILES = $(patsubst %.po,%.pox,$(POFILES)) | ||
|
||
%.mo: %.po | ||
mkdir -p $(shell dirname $@)/LC_MESSAGES | ||
msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $< | ||
|
||
# Generate MO files from PO files | ||
all-mo: $(MOFILES) | ||
|
||
# Check for malformed strings | ||
%.pox: %.po | ||
msgfmt -c $< | ||
pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \ | ||
-t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@ | ||
cat $@ | ||
! grep -q msgid $@ | ||
|
||
check: $(POXFILES) | ||
msgfmt -c ${POTFILE} | ||
|
||
# Merge PO files | ||
update-po: | ||
for f in $(shell find ./ -name "*.po") ; do \ | ||
msgmerge -N --backup=none -U $$f ${POTFILE} ; \ | ||
done | ||
|
||
# Unify duplicate translations | ||
uniq-po: | ||
for f in $(shell find ./ -name "*.po") ; do \ | ||
msguniq $$f -o $$f ; \ | ||
done | ||
|
||
tx-pull: | ||
tx pull -f | ||
for f in $(POFILES) ; do \ | ||
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \ | ||
done | ||
-git commit -a -m "i18n - extracting new, pulling from tx" | ||
|
||
extract-strings: | ||
bundle exec rake gettext:find | ||
|
||
reset-po: | ||
# merging po files is unnecessary when using transifex.com | ||
git checkout -- ../locale/*/*po | ||
|
||
tx-update: tx-pull extract-strings reset-po $(MOFILES) | ||
# amend mo files | ||
git add ../locale/*/LC_MESSAGES | ||
git commit -a --amend -m "i18n - extracting new, pulling from tx" | ||
-echo Changes commited! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Updating the translations | ||
------------------------- | ||
|
||
1. Check if there are any new languages with progress more than 50% on [transifex](https://www.transifex.com/projects/p/foreman/resource/hammer-cli-csv/). If so, do the following for each of the new languages: | ||
|
||
``` | ||
mkdir locale/<lang> | ||
cp locale/hammer_cli_csv.pot locale/<lang>/hammer_cli_csv.po | ||
``` | ||
2. Make sure you have `transifex-client` installed | ||
|
||
3. Update the translations. From GIT repo root directory run: | ||
|
||
``` | ||
make -C locale tx-update | ||
``` | ||
|
||
It will download translations from transifex, generates `mo` files, updates strings in `pot` file and wraps all the changes in a new commit. Transifex automatically updates its strings when the commit is pushed to Github. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: hammer_cli_csv 0.0.6\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-02-15 12:46-0500\n" | ||
"PO-Revision-Date: 2015-02-15 12:46-0500\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\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_csv/csv.rb:21 | ||
msgid "import to, or export from a running foretello server" | ||
msgstr "" |