Minification of localized strings

Overview

SmallStrings

Reducing localized .strings file sizes by 80%

How it works

The library consists of two main components:

  • A tool that converts the .strings files (of the form App.app/*.lproj/Localizable.strings) into a minified form as a build step. First, this tool eliminates key duplication by following the strategy from https://eisel.me/localization. This reduces the size by roughly 50%. Then, it keeps all these small files in a compressed form on disk, using LZFSE, reducing the size further. It also replaces the original language.lproj/Localizable.strings with placeholders that have one key-value pair each. This shows Apple that the same languages are still supported, so that it can pick the correct one based on the user's settings.
  • An iOS library that replaces NSLocalizedString with a new version, SSTStringForKey that fetches values for keys from this minified format.

Usage

Cocoapods

Add this to your Podfile:

pod 'SmallStrings'

Then add a Run Script build phase after the "Copy bundle resources" phase:

cd ${PODS_ROOT}/SmallStrings && ./localize.sh ${CODESIGNING_FOLDER_PATH} ${DERIVED_FILES_DIR}/SmallStrings.cache

Lastly, replace all usages of NSLocalizedString(key, comment) with SSTStringForKey(key).

Manual

Add Source/SSTSmallStrings.{h,m} to your project. Create a compress binary via clang -O3 compress.m -framework Foundation -lcompression -o compress and put the executable in the same directory as localize.{rb,sh}. Add a build step with cd /path/to/SmallStrings && ./localize.sh ${CODESIGNING_FOLDER_PATH} ${DERIVED_FILES_DIR}/SmallStrings.cache. Lastly, replace all usages of NSLocalizedString(key, comment) with SSTStringForKey(key).

You might also like...
Xcode plugin for quickly creating localized strings
Xcode plugin for quickly creating localized strings

Extractor Localizable Strings Extractor Localizable Strings is a open source plug-in for Xcode. It lets you extract localizable strings without openin

Generate Swift and SwiftUI symbols for localized strings files.
Generate Swift and SwiftUI symbols for localized strings files.

localized-strings-symbols An SPM and Xcode build plugin for creating Swift symbols for localized string keys. What It Does This is a very simple build

🌊 A clean wave - report unused localized strings
🌊 A clean wave - report unused localized strings

Ripple 🌊 Ripple - a command line tool that reports unused localization strings in your Xcode project. Install Clone from repo git clone cd Ripple sw

JSONHelper - ✌ Convert anything into anything in one operation; JSON data into class instances, hex strings into UIColor/NSColor, y/n strings to booleans, arrays and dictionaries of these; anything you can make sense of!

JSONHelper Convert anything into anything in one operation; hex strings into UIColor/NSColor, JSON strings into class instances, y/n strings to boolea

Validate iOS, Android, and Mac localizations. Find errors in .strings, .stringsdict, and strings.xml files.

Locheck An Xcode and Android localization file validator. Make sure your .strings, .stringsdict, and strings.xml files do not have any errors! What do

The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data.
The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data.

The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data. I have put together

Setting up application specific localized string within xib file.
Setting up application specific localized string within xib file.

LocalizedView ##What is this? LocalizedView is a helper class for setting up application specific localized string within Xib file. Here is a video de

OS font complements library. Localized font supported.
OS font complements library. Localized font supported.

SwiftFontName SwiftFontName is font name complements and supports localized font library. You don't need to search font name any more with SwiftFontNa

ScreenshotFramer - Create localized App Store screenshots
ScreenshotFramer - Create localized App Store screenshots

ScreenshotFramer With Screenshot Framer you can easily create nice-looking and localized App Store Images. How does it work? It's super simple: Screen

A μlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and emoji.

CountryKit CountryKit A μlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and e

EmbeddedStringsKit: Representation localized string in code

EmbeddedStringsKit Representation localized string in code Usage public struct L

Provides API access to localized musical instruments and their tunings.

instruments.fyi instruments.fyi provides API access to localized musical instruments and their tunings provided by InstrumentKit. Table of Contents Wo

Provides type-safe access to localized musical instruments and their tunings.

InstrumentKit InstrumentKit provides type-safe access to localized musical instruments and their tunings. Table of Contents Work In Progress Installat

The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.
Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.

Installation • Configuration • Usage • Build Script • Donation • Migration Guides • Issues • Contributing • License BartyCrouch BartyCrouch incrementa

Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.
Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.

Localize Localize is a framework written in swift to help you localize and pluralize your projects. It supports both storyboards and strings. Features

Super lightweight library that helps you to localize strings, even directly in storyboards!
Super lightweight library that helps you to localize strings, even directly in storyboards!

Translatio Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 9 or higher. Swi

µframework for Attributed strings.

Attributed µframework for Attributed strings. What is Attributed? Attributed aims to be a drop in replacement to the current version of the NSAttribut

A library for formatting strings on iOS and macOS

Sprinter Introduction What? Why? How? Usage Installation Integration Localization Thread Safety Advanced Usage Introduction What? Sprinter is a librar

Comments
  • Upgrade to a more modern language - lol

    Upgrade to a more modern language - lol

    I challenge you to find whether translating to Swift brings a performance cost.

    Seriously, I appreciate your work on optimizing Apple stuff, but I thought I'd do this just for kicks. It's a (hopefully) zero-cost literal translation from Objective-C to Swift, which I have a ton of experience with. I didn't mess with the compiled executable or podspec file.

    Please tell me what you think about it!

    opened by philipturner 9
  • SPM Support

    SPM Support

    I wonder if you'd be up for considering support for Swift Package Manager support, with the ability to create it as a plugin allowing for it to be easily run from within Xcode or the CLI.

    opened by Sherlouk 0
Owner
Emerge Tools
Build better mobile apps
Emerge Tools
Setting up application specific localized string within xib file.

LocalizedView ##What is this? LocalizedView is a helper class for setting up application specific localized string within Xib file. Here is a video de

darkcl 8 Oct 2, 2017
Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.

Installation • Configuration • Usage • Build Script • Donation • Migration Guides • Issues • Contributing • License BartyCrouch BartyCrouch incrementa

Flinesoft 1.3k Jan 1, 2023
Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.

Localize Localize is a framework written in swift to help you localize and pluralize your projects. It supports both storyboards and strings. Features

Andres Silva 279 Dec 24, 2022
Super lightweight library that helps you to localize strings, even directly in storyboards!

Translatio Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 9 or higher. Swi

Andrea Mario Lufino 19 Jan 29, 2022
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Jan 3, 2023
Localizable.strings files generator

Localizable.strings files generator When we want to internationalize our project always is a headache to maintain the Localizable.strings files. This

humdrum 30 Dec 18, 2022
Check Localizable.strings files of iOS Apps

Rubustrings Check the format and consistency of the Localizable.strings files of iOS Apps with multi-language support Rubustrings is also available fo

David Cordero 110 Nov 12, 2022
An application to convert strings to diffirent formats

Localized An application to convert strings to diffirent formats This app will help developers to convert strings from application in one platform to

null 16 Feb 12, 2021
Localizations is an OS X app that manages your Xcode project localization files (.strings)

Localizations 0.2 Localizations is an OS X app that manages your Xcode project localization files (.strings). It focuses on keeping .strings files in

Arnaud Thiercelin 129 Jul 19, 2022
Lists missing keys from .strings files.

strings-check A simple command line utility to check if translation strings are missing, or if extra translations are present in a set of .strings fil

Dave Clayton-Wagner 3 Nov 22, 2022