Git Product home page Git Product logo

nslocalizer's Introduction

nslocalizer

Code Climate Test Coverage CircleCI branch Dependency Status

This is a command line tool that is used for discovering missing and unused localization strings in Xcode projects.

Contributing and Code of Conduct License

This project and related material has a Code of Conduct that is listed in the contributing.md file. This must be read and adhered to when interacting with this project. Additionally this code is released under a 3-clause BSD license that you can read here.

Requirements Python

This tool is built and tested against Python 3.5.0.

Module Version
pbPlist >=1.0
pyobjc-core >= 2.5.1
pyobjc-framework-Cocoa >= 2.5.1
langcodes >= 1.2.0

Installation homebrew homebrew

Via homebrew:

$ brew update
$ brew tap samdmarshall/formulae
$ brew install samdmarshall/formulae/nslocalizer

To install the tool from the repo, clone from Github then run the make build command.

Usage

To use nslocalizer to generate warnings about missing or unused NSLocalizedStrings, you will have to pass it a project and target as input:

$ nslocalizer --project <path to xcodeproj file> --target <names of targets to analyze>

There are a number of flags that can be passed to modify the behavior of pyconfig:

Flags Usage
--version Displays the version of nslocalizer and exits
--find-missing Finds any strings that are missing translations for any of the supported languages
--find-unused Finds any strings that are unused in the code
--quiet Silences all logging output
--verbose Logs additional information
--ignore <languages> Will silence warnings for any of the languages listed to be ignored

Note: Both --find-missing and --find-unused flags can be supplied to the same invocation of nslocalizer.

Example

Find missing translation strings:

$ nslocalizer --project Foo.xcodeproj --target MyNewApp --find-missing
/Users/Samantha/Projects/Foo/Foo/Assets/Base.lproj/Localizable.strings:327: warning: String "foo_setup_twitter_integation" missing for: German, Traditional Chinese, European Portuguese, Spanish
/Users/Samantha/Projects/Foo/Foo/Assets/Base.lproj/Localizable.strings:356: warning: String "foo_setup_facebook_integation" missing for: German, Traditional Chinese, European Portuguese, Swedish, Polish, Latin American Spanish, British English, Brazilian Portuguese

Find unused translation strings:

$ nslocalizer --project Foo.xcodeproj --target MyNewApp --find-unused
/Users/Samantha/Projects/Foo/Foo/Assets/Base.lproj/Localizable.strings:327: warning: String "foo_setup_twitter_integation" is not used
/Users/Samantha/Projects/Foo/Foo/Assets/Base.lproj/Localizable.strings:356: warning: String "foo_setup_facebook_integation" is not used

Integration

nslocalizer is intended to be used as part of a build of the Xcode project file. To integrate you will have to add a new "run script" phase to your target and then invoke as such:

nslocalizer --project $PROJECT_DIR/YourProject.xcodeproj --target $TARGET_NAME --find-missing --find-unused

nslocalizer's People

Contributors

samdmarshall avatar

Watchers

James Cloos avatar Kiril Sivokoz 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.