doc/i18n.md in hammer_cli-0.11.0 vs doc/i18n.md in hammer_cli-0.12.0
- old
+ new
@@ -44,11 +44,10 @@
# register the domain
HammerCLI::I18n.add_domain(HammerCLIAwesomePlugin::I18n::LocaleDomain.new)
```
Then you have to export strings, translate them and place the files in a directory structure.
-Inspiration on how to export the translations can be found in hammer's [Rakefile](../Rakefile).
Typical directory structure for translation files look like this:
```
locale
├── de
@@ -60,11 +59,34 @@
│ └── LC_MESSAGES
│ └── hammer-cli-awesome.mo
└── hammer-cli-awesome.pot
```
+You can re-use Rake tasks and Makefile targets for extracting translations and integration with transifex that hammer provides.
+To do that, add following lines to the plugin's Rakefile:
+```ruby
+require "hammer_cli_awesome/version"
+require "hammer_cli_awesome/i18n"
+require "hammer_cli/i18n/find_task"
+HammerCLI::I18n::FindTask.define(HammerCLIAwesome::I18n::LocaleDomain.new, HammerCLIAwesome.version)
+```
+and create `locale/Makefile` with following content:
+```make
+DOMAIN = hammer-cli-awesome
+VERSION = $(shell bundle exec ruby -e 'require "rubygems"; spec = Gem::Specification::load("../hammer_cli_awesome.gemspec"); puts spec.version')
+MAIN_MAKEFILE = $(shell bundle exec ruby -e 'require "hammer_cli"; puts HammerCLI::I18n.main_makefile')
+
+include $(MAIN_MAKEFILE)
+```
+
+Make sure you have a project created in [transifex](www.transifex.com) and correct configuration stored in your plugins repository ([example config file](../.tx/config)).
+
+
+Calling `make -C ./locale tx-update` will then extract new strings, update `.po` and `.mo` files and commit the changes.
+
+
### Translation tips
When writing code with translations make sure you keep two following rules:
1) Don't use variables directly in the strings and make formatting substitutions outside the gettext function `_("...")`.
@@ -94,7 +116,16 @@
"\n - " + _("make dishes") +
"\n - " + _("do shopping")
```
-4) Try setting `:mark_translated: true` to identify gaps in your translations.
+4) It's recommended to use punctuation at the end of sentences.
+```ruby
+# CORRECT
+puts _("Hello %s") % name
+# RECOMMENDED
+puts _("Hello %s.") % name
+```
+
+
+5) Try setting `:mark_translated: true` to identify gaps in your translations.
This will wrap all translated strings with angle brackets '>message<'.