https://github.com/mntnorv/puttext
Extract gettext strings from Ruby source
https://github.com/mntnorv/puttext
extract gettext ruby slim
Last synced: about 1 month ago
JSON representation
Extract gettext strings from Ruby source
- Host: GitHub
- URL: https://github.com/mntnorv/puttext
- Owner: mntnorv
- License: mit
- Created: 2017-04-10T13:16:55.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-07T13:38:12.000Z (about 9 years ago)
- Last Synced: 2025-12-31T21:16:47.530Z (6 months ago)
- Topics: extract, gettext, ruby, slim
- Language: Ruby
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://badge.fury.io/rb/puttext)
[](https://travis-ci.org/mntnorv/puttext)
[](https://codeclimate.com/github/mntnorv/puttext)
[](https://codeclimate.com/github/mntnorv/puttext/coverage)
# puttext
Put translatable gettext strings from your Ruby code to a `.po` or `.pot` file.
For example, if you have this `translatable.rb` file:
```ruby
puts _('translatable string')
```
You get this output:
```po
#: translatable.rb:1
msgid "translatable string"
msgstr ""
```
## Language support
Supports extracting strings from these types of files:
- Ruby
- Slim
## Installation
Using RubyGems:
```bash
$ gem install puttext
```
Or add it to your `Gemfile` if using Bundler:
```ruby
gem 'puttext', require: false
```
Also, if you want additional language support beyond plain Ruby, install these gems:
- [**slim**](https://github.com/slim-template/slim) for Slim support.
## Usage
Just run the `puttext` command line tool and point it to your Ruby project:
```bash
$ puttext /path/to/your/project
```
### Options
#### `-o`, `--output`
By default `puttext` will output the extracted PO file contents to stdout. You can write the output to a file by specifying the `-o`, `--output` option.
```bash
$ puttext /path/to/your/project -o template.pot
```
## Contributing
Before submitting an Issue or Pull Request always check if your issue is already being discussed or if someone has already submitted a pull request with the feature you want to add. Also, before doing bigger changes, it's always good to discuss the changes you're going to make in an Issue.
### Code style
PutText uses RuboCop (https://github.com/bbatsov/rubocop) to check and enforce code style. Before submitting a pull request, make sure that RuboCop does not find any offenses.
#### Running RuboCop
```bash
$ bundle exec rubocop
```
### Testing
PutText uses RSpec (http://rspec.info/) for testing. Pull requests with Ruby code changes must include RSpec tests that check the new functionality or changed code. Also, make sure that your changes do not break any existing tests.
#### Running RSpec
```bash
$ bundle exec rspec
```