Skip to main content

XCodeLocalize

Requirments

Python3.9+

Installation

Using pip:

pip3 install xcodelocalize 

Аlso available installations via poetry or .whl file from github releases

Usage

Prepare your xcode project

  1. Create Localizable.strings file and fill it with strings you want to localize.

    /* optional description */
    "[key]" = "[string]";
    
    /* Example: */
    "welcome text" = "Welcome to XCodelocalize";
    
  2. Go to the project settings, add the desired languages.

  3. Create localization (.strings) files for all selected languages.

There is a nice tutorial about ios app localization by kodeco (the new raywenderlich.com)

Localize

cd to project root folder and run

xcodelocalize [OPTIONS]

or

python3 -m xcodelocalize [OPTIONS]

Options

  • --base-language: code of the language from which all strings will be translated. [default: 'en']

  • --override / --no-override: a boolean value that indicates whether strings that already exist in the file will be translated. Retranslate if override, skip if no-override. [default: no-override]

  • --format-base / --no-format-base: sort base file strings by key. [default: no-format-base]

  • --file: Names of the strings files to be translated. Multiple files can be specified. If not specified, all files will be translated. [default: None]

    Example:

    xcodelocalize --file InfoPlist
    xcodelocalize --file InfoPlist --file MainStoryboard --file Localizable 
    
  • --key: Keys of the strings to be translated. Multiple keys can be specified. If not specified, all keys will be translated. [default: None]

  • --language: Language codes of the strings files to be translated. Multiple language codes can be specified. If not specified, all files will be translated. [default: None]

  • --log-level: One from [progress|errors|group|string]. [default: group]

  • --help: Show info

Features:

  • The tool looks for .strings files in the current directory recursively, grouping and translating fully automatically. You can even run it in the root directory and localize all your projects at once.

  • Regular .strings, Info.plist, storyboards and intentdefinition files are supported.

  • Formated strings with %@ are supported.

  • Multiline strings are supported.

  • Comments are supported and will be copied to all files. Comments must not contain substrings in localizable strings format with comment, such as /*[comment]*/ "[key]" = "[value]";.

Automation

You can go to Target -> Build Phases -> New Run Script Phase in your xcode project and paste xcodelocalize there. It will localize necessary strings during build and your localization files will always be up to date.


Bonus

Nice swift extension that allows you to do this

"welcome text".localized // will return "Welcome to XCodelocalize"
extension String {
    var localized: String {
        NSLocalizedString(self, tableName: nil, bundle: .main, value: self, comment: "")
    }
    
    func localized(_ arguments: String...) -> String {
        String(format: self.localized, locale: Locale.current, arguments: arguments)
    }
}

Release files for xcodelocalize 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xcodelocalize 1.0.3
File Size Uploaded
xcodelocalize-1.0.3.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xcodelocalize 1.0.3
File Interpreter ABI Platform
xcodelocalize-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size:13.6 kB

Release files / xcodelocalize-1.0.3.tar.gz

Download URL xcodelocalize-1.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0bc106d2d40ecbf83e6560b9e654ea7edbde1e679042f34037937c2a443dc99f
BLAKE2b-256 checksum
How to use checksums
3f4780e3ea28d86d76eb95d61a29d2e4432b3a0aa5c06b0f174301b1140b6715
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / xcodelocalize-1.0.3-py3-none-any.whl

Download URL xcodelocalize-1.0.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c750f332fb4e167f536e78a4618c9f9fc2d4fedf089ce46bcace65c85caba942
BLAKE2b-256 checksum
How to use checksums
56a118ef297c5040a9aa99bd32be7cbc02712379ddd75cbb8244025c9adce4ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page