nslocalized
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
In some cases you might want to load the string table without processing escapes. In that case, you can do:
>>> st = StringTable.read('/path/to/my/Localized.strings',
process_escapes=False)
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)
Metadata
Release files for nslocalized 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nslocalized-0.2.0.tar.gz | 6.1 kB | Without provenance | Details for nslocalized-0.2.0.tar.gz |
Release files / nslocalized-0.2.0.tar.gz
| Download URL | nslocalized-0.2.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46d6f776b26e9da0e0d0c759d99782884882cade59d5c935005a85cba654db9e
|
|
BLAKE2b-256 checksum How to use checksums |
77b7610c101e59810d9d54d5308df8531ca401528a2d9cd3014e26d01b7be9e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for nslocalized 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.