Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Reads and writes Mac OS X .strings files

Project description

What is this?

It’s a package of Python code for manipulating Mac OS X/iOS .strings files, which has been written carefully to support all of the character escapes and Unicode characters you might wish to use.

How do I use it?

To read a .strings file:

>>> from nslocalized import StringTable
>>> st ='/path/to/my/Localized.strings')

or to read the strings into an existing StringTable:


To write a new .strings file:

>>> st.write('/path/to/my/new/Localized.strings')

By default, that uses host-endian UTF-16, but you can specify the encoding:

>>> st.write('/path/to/my/new/Localized.strings', encoding='utf_8')

Each string is represented by a LocalizedString object; given the strings file:

/* My important string */
"Very important" = "Très important";

in a StringTable st:

>>> ls = st.lookup('Very important')
>>> print ls.source
Very important
>>> print
Très important
>>> print ls.comment
My important string

You can also add entries to a StringTable with:

>>>'One', 'Uno'))

or with a comment:

>>>'MB', 'Mo', 'Megabytes'))

Finally, for simple access you can use the [] operator:

>>> st['GB'] = 'Go'
>>> print st['MB']

In some cases you might want to load the string table without processing escapes. In that case, you can do:

>>> st ='/path/to/my/Localized.strings',

which will read the table without any escape processing taking place. Obviously if you read a table in this form, you will also want to write it without escaping:

>>> st.write('/path/to/my/new/Localized.strings', escape_strings=False)

Project details

Release history Release notifications

This version
History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
nslocalized-0.2.0.tar.gz (6.1 kB) Copy SHA256 hash SHA256 Source None Jan 11, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page