A simple Swift utility for producing pseudolocalized strings

Pseudolocalize

Build your App UI to adapt and respond to translations, and find localization bugs!


Usage

pseudolocalize("Hello")
  // "[~Hêëèllóøõ~]"

Using in an app

Here is how you might override the built-in NSLocalizedString(_:comment:) handler in a simple iOS App:

#if DEBUG
import Foundation
import pseudolocalize

func NSLocalizedString(_ key: String, comment: String) -> String {
  let value = NSLocalizedString(key, tableName: nil, bundle: Bundle.main, value: "", comment: "")
  return pseudolocalize(value)
}
#endif

For apps with more complex abstraction or multiple strings files, you may want to generate/preprocess your en.lproj/*.strings files and run pseudolocalize() as a Build Phase.

Advanced usage

There are a number of different options you can take advantage of.

pseudolocalize("Hello"
               accents: true,
               vowelExpansions: 2,
               idealExpansionRate: 2.0,
               encapsulated: true)

Features

  • Accenter: Replaces the vowels of your string with extended character versions.
  • Encapsulator: Wraps your text in brackets to highlight issues with concatenation.
  • Expander: Makes your text longer to simulate the length of other languages.

License

MIT License

GitHub

https://github.com/reececomo/pseudolocalize-swift