Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aergonaut/pseudo_l10n
π Simple utility for pseudo-localization in Ruby
https://github.com/aergonaut/pseudo_l10n
g11n i18n internationalization l10n localization pseudo-localization
Last synced: 26 days ago
JSON representation
π Simple utility for pseudo-localization in Ruby
- Host: GitHub
- URL: https://github.com/aergonaut/pseudo_l10n
- Owner: aergonaut
- License: mit
- Created: 2022-12-08T00:15:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T16:42:53.000Z (4 months ago)
- Last Synced: 2024-10-04T06:22:26.352Z (about 1 month ago)
- Topics: g11n, i18n, internationalization, l10n, localization, pseudo-localization
- Language: Ruby
- Homepage: https://rubygems.org/gems/pseudo_l10n
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `PseudoL10n`
`PseudoL10n` is a simple gem to add pseudolocalization to Ruby projects.
## Installation
Add this line to your application's Gemfile:
```ruby
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:
```ruby
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:```ruby
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:```ruby
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.
```ruby
message = "Hello world"PseudoL10n::Transformer.call(message)
# => "βοΌ¨ο½ ο½ο½ο½ ο½ο½ο½ο½ο½β"
```## 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](https://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](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## 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](https://github.com/[USERNAME]/pseudo_l10n/blob/master/CODE_OF_CONDUCT.md).