<commit_before># G11n is Globalization
[![Build Status](https://secure.travis-ci.org/Fetcher/g11n.png)](http://travis-ci.org/Fetcher/g11n) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Fetcher/g11n)

Globalization (g11n) is a Ruby Gem for easy language file handling aimed at internationalized projects.

The developers of g11n are well aware of the existence of both i18n and r18n Ruby Gems, but wanted a new approach (specially in terms of simplicity) and this is the answer.

## Usage

G11n assumes you will have a series of language files written in YAML in an accessible folder to your project, named after each language's locale and followed by the YAML extension. Both `.yaml` and `.yml` extensions are recognized.

The default path for that folder is `translations/`. So, for example, if you have a file named `translations/it.yaml` that reads as...

```yaml
# ./translations/it.yaml
home:
  title: La pasta della nonna
  menu:
    preparation: Comme farla
    eating: Comme si mangia
    wine: Con che si accompagna
```

... you can, in your project, insert the following code and get the internationalized strings:

```ruby
# .script.rb
require "g11n"

G11n.locale :it                             # Configures G11n to use italian. Default is "en"
G11n.locale                                 # => :it

G11n.t.home.title                           # => "La pasta della nonna"
G11n.t.home.menu.wine                       # => "Con che si accompagna"
```
    
## Installation

    gem install g11n

### Or when using Bundler

Add this line to your application's Gemfile:

    gem 'g11n'

And then execute:

    bundle install

## Configuring

Configuration is straight forward. You are using another directory for your language files? Just `G11n.path "your/path"`. You want to change the locale? `G11n.locale :yours`.

For example, a translations file in a non-standard folder:

```yaml
# ./i18ns/ru.yml
home:
  land: Российская Федерация
```

And a script in the base folder:

```ruby
# ./script.rb
require "g11n"

G11n.path "i18ns"
G11n.locale :ru

G11n.t.home.land                           # => "Российская Федерация"
```

Also, the `G11n::DSL` module can be included in any object of class you want to use the `#t` method more confortably.

## Use it in Sinatra
The G11n DSL (the `#t` and `#translate` methods) are as a module unsurprisingly called `G11n::DSL`. You can of course include in into your helpers as easy as:

```ruby
# .app.rb
require 'sinatra'
require 'g11n'

helpers G11n::DSL

G11n.locale :es

get '/' do
  t.welcome                             # => "¡Bienvenido, amigo!" 
                                        # as described in the es.yaml
end
```

```yaml
# .translations/es.yaml
welcome: ¡Bienvenido, amigo!
```

It works in modular style also.

## Testing

Cucumber features and RSpec specs are provided to check functionality.

## License

Copyright (C) 2012 Fetcher

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.<commit_msg>Readme corrections [ci skip]<commit_after># G11n is Globalization
[![Build Status](https://secure.travis-ci.org/Fetcher/g11n.png)](http://travis-ci.org/Fetcher/g11n) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Fetcher/g11n)

Globalization (g11n) is a Ruby Gem for easy language file handling aimed at internationalized projects.

The developers of g11n are well aware of the existence of both i18n and r18n Ruby Gems, but wanted a new approach (specially in terms of simplicity) and this is the answer.

## Usage

G11n assumes you will have a series of language files written in YAML in an accessible folder to your project, named after each language's locale and followed by the YAML extension. Both `.yaml` and `.yml` extensions are recognized.

The default path for that folder is `translations/`. So, for example, if you have a file named `translations/it.yaml` that reads as...

```yaml
# ./translations/it.yaml
home:
  title: La pasta della nonna
  menu:
    preparation: Comme farla
    eating: Comme si mangia
    wine: Con che si accompagna
```

... you can, in your project, insert the following code and get the internationalized strings:

```ruby
# .script.rb
require "g11n"

G11n.locale :it                             # Configures G11n to use italian. Default is "en"
G11n.locale                                 # => :it

G11n.t.home.title                           # => "La pasta della nonna"
G11n.t.home.menu.wine                       # => "Con che si accompagna"
```
    
## Installation

    gem install g11n

### Or when using Bundler

Add this line to your application's Gemfile:

    gem 'g11n'

And then execute:

    bundle install

## Configuring

Configuration is straight forward. You are using another directory for your language files? Just `G11n.path "your/path"`. You want to change the locale? `G11n.locale :yours`.

For example, a translations file in a non-standard folder:

```yaml
# ./i18ns/ru.yml
home:
  land: Российская Федерация
```

And a script in the base folder:

```ruby
# ./script.rb
require "g11n"

G11n.path "i18ns"
G11n.locale :ru

G11n.t.home.land                           # => "Российская Федерация"
```

Also, the `G11n::DSL` module can be included in any object of class you want to use the `#t` method more confortably.

## Use it in Sinatra
The G11n DSL (the `#t` and `#translate` methods) are available as a module unimaginatively called `G11n::DSL`. You can of course include it into your helpers as easy as:

```ruby
# .app.rb
require 'sinatra'
require 'g11n'

helpers G11n::DSL

G11n.locale :es

get '/' do
  t.welcome                             # => "¡Bienvenido, amigo!" 
                                        # as described in es.yaml
end
```

```yaml
# .translations/es.yaml
welcome: ¡Bienvenido, amigo!
```

It works in modular style too.

## Testing

Cucumber features and RSpec specs are provided to check functionality.

## License

Copyright (C) 2012 Fetcher

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
{'fraction_non_alphanumeric': 0.08747404844290657, 'fraction_numerical': 0.018546712802768164, 'mean_word_length': 2.9659714599341385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1286385', 'n_tokens_mistral': 2264, 'n_tokens_neox': 2139, 'n_words': 912}