Project

apfel

0.02
No commit activity in last 3 years
No release in over 3 years
Parse valid .strings files for easy conversion to other formats
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0
 Project Readme

Apfel

Introduction

Apfel is simple parser for .strings (DotStrings) files written in Ruby. DotStrings files are used by Apple platforms for localization. Apfel reads DotStrings files, parses them for key-value pairs and comments.

Once in the form of a hash, the content of the DotStrings file can easily be rebuilt as JSON, XML and RESX (with the help of Builder https://github.com/jimweirich/builder) and more!

Use

To start using Apfel first require the gem

require 'apfel'

Next, pass Apfel the .strings file you want to parse:

parsed_file = Apfel.parse('path/to/file')

Once the file has been parsed, you can do many things with it:

# Turn it into a ruby hash (includes comments)
parsed_file.to_hash

# Turn it into json (includes comments)
parsed_file.to_json

# With either #to_hash or #to_json you can specify
# whether you want the comments included
parsed_file.to_hash(with_comments: false)

# Get all the keys as an array
parsed_file.keys

# Get all the values as an array
parsed_file.values

# Return an array of key-value hashes
parsed_file.key_values

# Return an array of key-comment hashes
parsed_file.comments

# Return an array of all the comments without their keys
parsed_file.comments(with_keys: false)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Commit tests (they should pass when rake is run)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request