GomaShika

GomaShika is a CLI tool to extract and convert data from CLDR into formats that Ruby's I18n gem can utilize.

Installation

TODO: Replace UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.

Install the gem and add to the application's Gemfile by executing:

bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

If bundler is not being used to manage dependencies, install the gem by executing:

gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

Usage

GomaShika uses a config file that determines what data to export. Different data is exported depending on your specific configuration. The following sections describe the different configuration parameters and what data can be exported.

An example config can be found in the spec/ directory.

Target locales

List the locales you wish to generate data for in the locales key. This should be a list of locale codes, generally matching the locales you set in I18n.available_locales.

locales:
  - en
  - zh

GomaShika will run all of its extractions and conversions for each locale you specify in this list.

Date, Time, and DateTime Formats

List date, time, and datetime formats under the formats key of the config file:

formats:
  short_date_time:
    date_time:
      pattern_style:
        type: :medium:
      date_style:
        type: :short:
      time_style:
        type: :medium:

formats.<name>

Each key under formats will become a named format in the output. GomaShika duplicates your formats under both date.formats.* and time.formats.* so you can consistently access any format, whether you are localizing a Date or a Time.

formats.<name>.(date|time)

Specify date or time after <name> to create a date or time format. The format must contain a type key with a value of either short, medium, long, full, or additional. If the type is additional, then additional_format must also be supplied. additional_format must be one of the flexible formats defined by CLDR. Not all languages support all formats, so check the CLDR documentation to confirm coverage.

formats.<name>.date_time

Use date_time to specify a combined format showing both date and time. This format requires 3 keys: pattern_style, date_style, and time_style.

pattern_style describes the pattern used to combine the formatted date and time. This must be one of short, medium, long, or full. Note that for many languages some of these patterns will be identical. full and long both generally resolve to the at formats from CLDR.

date_style and time_style follow the rules of date and time formats above.

Development

After checking out the repo, run bin/setup to install dependencies. 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 the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/goma_shika. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the 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 GomaShika project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.