Skip to content

aergonaut/pseudo_l10n

Repository files navigation

PseudoL10n

PseudoL10n is a simple gem to add pseudolocalization to Ruby projects.

Installation

Add this line to your application's Gemfile:

gem 'pseudo_l10n'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pseudo_l10n

Usage

Integration with I18n

This gem provides a PseudoL10n::Backend class that is compatible with the i18n gem to provide automatic pseudolocalization to your project.

To use the backend, wrap your existing I18n.backend with the Backend class from this gem:

I18n.backend = PseudoL10n::Backend.new(I18n.backend)

Pseudo-Locale

This gem generates a pseudo-locale at runtime by applying varius transformations to strings from the source locale. By default the source locale is :en. You may change the source locale by setting PseudoL10n.source_locale to a different value:

PseudoL10n.source_locale = :de

To activate pseudolocalization, set the current I18n.locale to the special pseudolocale code. By default, this code is the source_locale code with -ZZ appended. For example, the pseudo-locale code for :de would be de-ZZ. You may change the pseudo-locale code by setting PseudoL10n.pseudo_locale to a different value:

PseudoL10n.pseudo_locale = :qps

Low-level Transformer API

This gem also provides a low-level transformer API. This can be used to transform a string according to pseudolocale rules.

message = "Hello world"

PseudoL10n::Transformer.call(message)
# => "√Hello world√"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pseudo_l10n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PseudoL10n project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.