Latest 3.0.0
License MIT
Platforms ios 8.0, requires ARC


ZenText is the easiest way to manage the text of your iOS app.
With ZenText you can:

  • Style NSAttributedStrings with ease, with or without regex matching (1 line!)
  • Localize styled NSAttributedStrings
  • Store all your strings in one place (instead of across multiple files)


ZenText is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ZenText"


To run the example project, clone the repo, and run pod install from the Example directory first.


Configuring Copy

You’ll notice that Copy can include args. Simply use $0, $1, … to set your args. Order within the text doesn’t matter.

// english chat copy. prefix is for establishing context (optional)
ZenText.manager.config.addCopy("en", prefix: "chat") {
  return [
    "dance": ["@$0 dances with themself"], // note: this is

// spanish chat copy
ZenText.manager.config.addCopy("sp", prefix: "chat") {
  return [
    "dance": ["@$0 baila con sí mismos"], // note: this is

Using Copy


myLabel.attributedText = ZenText.manager.attributedString(key: "", args: [sender, other])


Configuring Styles

ZenText.manager.config.setStyles {
    return [
        "action": Style(
            color: .lightGrayColor()
        "token": Style(
            color: .blueColor(),
            fontSize: 14
        "hulk": Style (
            color: .greenColor(),
            fontSize: 40

Set Style on NSAttributedString (with Regex!)

let atUserRegex = "(@[A-Za-z0-9_]*)"
mutableAttributedString.regexFind(atUserRegex, addStyle: "token")

Styling in copy

In this example, chat.poke has arguments $0 and $1 styled as "token"

ZenText.manager.config.addCopy("en", prefix: "chat") {
  return [
    "poke": ["@$0 ".style("token"), "pokes ", "@$1".style("token")] // note: this is chat.poke

Additional notes

I recommend storing all your strings in a Copy.swift (name it what you want) file within your project. I also recommend making use of the copy ‘prefixes’ to separate your keys by context (e.g. "global", "profile", "chat", etc.)

Let me know if you have any questions! Please submit feedback, issues, and pull requests :D


  • Have option to automatically set ZenText localization from device localization. Currently this is manual.
  • Scripts to help you work with or migrate NSLocalizedStrings
  • Clean integrations with other useful NSAttributedString libraries


JP McGlone, [email protected]


ZenText is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "ZenText",
    "version": "3.0.0",
    "summary": "ZenText makes NSAttributedStrings EASY! It also functions as a Copy and Localization tool.",
    "description": "ZenText makes NSAttributedStrings easy! It also functions as a Copy and Localization tool. Check it out and leave me some feedback.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "JP McGlone": "[email protected]"
    "source": {
        "git": "",
        "tag": "3.0.0"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "requires_arc": true,
    "source_files": "ZenText/Classes/**/*"

Pin It on Pinterest

Share This