Giter VIP home page Giter VIP logo

rescodegen's Introduction

rescodegen

A command line tool for creating Swift and Objective-C code from singular Localizable.strings and plural Localizable.stringsdict.

Installation

$ sudo gem install rescodegen

Usage

Generate Code

$ rescodegen -i Localizable.strings

Options

Option Value Required Default Description
-i relative/path/to/Localizable.strings ✔️ The input file(s). Must be .strings or .stringsdict format. You may specify more than 1 file.
-l swift or objc swift The language of the generated code.
-o relative/path/to/output/directory . Where to save generated files.
-p e.g. SH An optional prefix to apply to Objective-C types.

Example

Localizable.strings

...
/* Error message to display when uploading an image fails. */
"Uploader.ErrorAlert.Message" = "The upload failed.";
...

Localizable.stringsdict

...
    <key>Uploader.ProgressLabel.Text</key>
	<dict>
		<key>NSStringLocalizedFormatKey</key>
		<string>Uploading %#@images@.</string>
		<key>images</key>
		<dict>
			<key>NSStringFormatSpecTypeKey</key>
			<string>NSStringPluralRuleType</string>
			<key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>one</key>
            <string>one image</string>
			<key>other</key>
			<string>%d images</string>
		</dict>
	</dict>
...

Generate Code

$ rescodegen -i Localizable.strings -i Localizable.stringsdict
$ rescodegen -i Localizable.strings -i Localizable.stringsdict -l objc

Xcode

Drag the generated files into Xcode and add them to your target.

Swift

Access localized singular strings:
Strings.Singular.uploader_errorAlert_message.localizedString => "The upload failed."
Access localized plural strings:
Strings.Plural.uploader_progressLabel_text.localizedString(1) => "Uploading one image."

Objective-C

Access localized singular strings:
LocalizedSingularString(SingularString_uploader_errorAlert_message) => "The upload failed."
Access localized plural strings:
LocalizedPluralString(PluralString_uploader_progressLabel_text, 2) => "Uploading 2 images."

Encoding

rescodegen currently only supports UTF-8 encoding.

rescodegen's People

Contributors

seanhenry avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.