Giter Site home page Giter Site logo

localize's Introduction

Localize

Localize

Language: Swift Platform: iOS codebeat badge License: MIT Release version

Localize is a tiny run script that keeps your Localizable.strings files clean and emits warnings when something is suspicious.

Localize

Because Localization files tend to rot over time and become a hassle to work with. Stressful when you have to test your app against many different Localizations.

Try it!

Localize is part of freshOS iOS toolset. Try it in an example App ! Download Starter Project

How

By using a script running automatically, you have a safety net keeping them sane, checking for translation issues and preventing then to rot over time.

What

Automatically (On build)

  • Cleans you localization files (removes spaces)
  • Sorts keys Alphabetically
  • Checks for Unused Keys
  • Checks for Missing Keys
  • Checks for Untranslated (which you can ignore with a flag)

Installation

Add the following Run Script in XCode, this will run the script at every build. Use the path of where you copied Localize.swift script

${SRCROOT}/{REPLACE ME}} # Ex: ${SRCROOT}/Libs/Localize.swift

Run and Enjoy \o/

Configuration

Configure the top section of the Localize.swift according to your project

More

Ignore [Potentialy Untranslated] warnings

Just Add //ignore-same-translation-warning next to the translation. Example :

"PhotoKey" = "Photo"; //ignore-same-translation-warning

This will take care of ignoring [Potentialy Untranslated] "XXX" in FR file doesn't seem to be localized

Unused false positive

Not found by the script reason 1

The script parses your project sources and checks if your keys are called within NSLocalizedString calls. But chances are you have a helper for a shorter NSLocalizedString syntax. This is indeed supported but you have to give the script what to look for.

You can modify the script to include other ways of localizations:

let patterns = [
    "NSLocalizedString\\(@?\"(\\w+)\"", // Swift and Objc Native
    "Localizations\\.((?:[A-Z]{1}[a-z]*[A-z]*)*(?:\\.[A-Z]{1}[a-z]*[A-z]*)*)", // Laurine Calls
    //Add your own matching regex here
    "fsLocalized\\(@?\"(\\w+)\""
]

Not found by the script reason 2

Another common pattern is to have keys being built at runtime. Of course thoses keys are not present at compile time so the script can't know about them and emits false positive errors. You can add those keys at the top of of the script to prevent this from happening:

let ignoredFromUnusedKeys = [
    "NotificationNoOne",
    "NotificationCommentPhoto",
    "NotificationCommentHisPhoto",
    "NotificationCommentHerPhoto"
]

Author

Sacha Durand Saint Omer, [email protected]

Contributors

JuliusBahr, ezisazis

Contributing

Contributions to Localize are very welcomed and encouraged!

License

Localize is available under the MIT license. See LICENSE for more information.

Backers

Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site :)

localize's People

Contributors

albinekcom avatar ay8s avatar ezisazis avatar goff-marocchi avatar nikkovios avatar s4cha avatar sionleroux 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.