Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gettext_swap

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettext_swap

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 07 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc