0.0
No commit activity in last 3 years
No release in over 3 years
Uses a special wrapper fast_gettext repository to replace translated string in runtime. The set of rules is pecified in a yaml file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0

Runtime

 Project Readme

GettextSwap

This gem adds the ability to swap words in strings marked for translation. It is an extension to fast_gettext.

For example, given you have set the system to replace <my project> with GettextSwap:

swapped = _('Welcome to <my project')
# => 'Welcome to GettextSwap'

Installation

Add this line to your application's Gemfile:

gem 'gettext_swap'

And then execute:

$ bundle

Usage

First you have to build a yaml file that will contain the rules for the swapper.

  1. The yaml should contain a main root element swap
  2. Each rule consists of two sub elements: search - regular expression to search in the source, and replace - the string to use for replacement.

Example:

swap:
  - search: '\bForeman\b(?!-)'
    replace: 'Satellite'
  - search: '\bsmart proxy\b(?!-)'
    replace: 'capsule'
  - search: '\bproxy\b(?!-)'
    replace: 'Capsule'

To apply the rules, point GettextSwap to the file containing the rules.

GettextSwap.configure 'config/test/test.yaml'

Development

This gem uses rubocop to validate styling and minitest framework for testing. Run rubocop and rake test to verify your code.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ShimShtein/gettext_swap.

License

See LICENSE file.