Skip to main content

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 = StringTable.read('/path/to/my/Localized.strings')

or to read the strings into an existing StringTable:

>>> st.read('/path/to/my/other/Localized.strings')

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 ls.target
Très important
>>> print ls.comment
My important string

You can also add entries to a StringTable with:

>>> st.store(LocalizedString('One', 'Uno'))

or with a comment:

>>> st.store(LocalizedString('MB', 'Mo', 'Megabytes'))

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

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

Project details


Download files

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

Source Distribution

nslocalized-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file nslocalized-0.1.0.tar.gz.

File metadata

  • Download URL: nslocalized-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nslocalized-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4cb50d35aa7e16ad4cc4d09996387f822446687be8eac703d454f8ca62e43988
MD5 38b79d50d18abc41c88226c817c5eac3
BLAKE2b-256 1e83ef54663caf79d2e3ced11f8dd17b58d802e453247d298eb7aafc248725e2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page