Latest 0.9.3
Homepage https://github.com/mbieda/QALocalize
License MIT
Platforms ios 10.0, requires ARC

Framework supporting quality assurance tests of the app with different localizations.

Should I read more?

  • Ever worked on multi language iOS app?
  • Ever had problems with real strings not fiting delivered mockups?
  • Ever being tired of hours spent on testing app layout for different languages to find potential problems?

If at least one answer is YES, then it might be worth to continue reading.

Why should I use it?

What looks fine on mockups might fail during quality assurance tests of the app in other languages, on different devices.

Real Test Problems

When adding localizations to our app we always should check if the strings look well in the app. However it may be tough / time consuming / boring to validate all languages, that is why it’s better to let the app pick most problematic strings for us and display them at once.

Test Solution

What are the benefits?

  • Build the app with longest / shortest / production translations to check how the app looks like in case of corner cases.
  • Choose source of translations between automatic and manual.
  • Use with both Swift and Objective-C projects.
  • Simply intergrate with already implemented extentions/categories/methods supporting localizing the app.
  • And, last, but not least, instantly find UI problems related to strings across the whole app.

Installation

Using CocoaPods:

Simply add the following line to your Podfile:

pod 'QALocalize'

Usage

Configuration during app lifetime

Simply call qaLocalize() on String key to return translation.

self.loginField.placeholder = "keyUsername".qaLocalize()
self.loginButton.setTitle("keySignIn".qaLocalize(), for: .normal)
self.termsLabel.text = "keyTerms".qaLocalize()

Configuration at app launch

Import

import QALocalize

Mode

  1. Production (default) – to be always used when releasing production build
    QALocalizeManager.shared.mode = .production
  2. Test Longest String – to return longest translation for the key
    QALocalizeManager.shared.mode = .testLongestString
  3. Test Shortest String – to return shortest translation for the key
    QALocalizeManager.shared.mode = .testShortestString

Source

  1. Automatic (default) – scans main app bundle looking for all Localizable.strings files and loads translations from them.
    QALocalizeManager.shared.source = .automatic
  2. Manual – requires developer to manually add all localizations that should be used to feed the app with best translations.
    QALocalizeManager.shared.source = .manual
    QALocalizeManager.shared.addManualLocalization(map: ["keyOne":"One", "keyTwo":"Two", "keyThree":"Three", "keyFour":"Four"], for: "en-en")

Production fallback support

IMPORTANT – don’t forget to add this method for production version, otherwise QALocalize with return raw key.

QALocalizeManager.shared.passByBlockPressed({(key: String) in
  return NSLocalizedString(key, comment: "") // <--- put your current translation method here
})

Bonus – sample test ViewController to switch QALocalize Mode & Source on the fly

To change QALocalize Mode or Source without recompiling the app you can use simple ViewController. Please note, that after changing Mode or Source you need to call qaLocalize() method again on each UI element you want to check.

let qaBundle = Bundle(for: QALocalizeViewController.self)
if let vc = UIStoryboard(name: "QALocalize", bundle: qaBundle).instantiateViewController(withIdentifier: "QALocalizeViewController") as? QALocalizeViewController {
  vc.closeBlockPressed {
    vc.dismiss(animated: false, completion: nil) // <--- use your preferred closing method
  }
  self.present(vc, animated: false, completion: nil) // <--- use your preferred opening method
}

Sample configuration scenarios

  1. Test longest strings from Localizable.strings in Swift
    
    import QALocalize

QALocalizeManager.shared.mode = .testLongestString
QALocalizeManager.shared.source = .automatic

2. Test shortest strings from manual translation maps in **Objective-C**
```objective-c
#import "QALocalize/QALocalize-Swift.h"

QALocalizeManager.shared.mode = QALocalizeModeTestShortestString;
QALocalizeManager.shared.source = QALocalizeSourceManual;
[QALocalizeManager.shared addManualLocalizationWithMap:@{@"keyUser":@"User", @"keyPassword": @"Password"} for:@"en"];    
  1. Release for production from Localizable.strings in Swift
    
    import QALocalize

QALocalizeManager.shared.mode = .production
QALocalizeManager.shared.source = .automatic
QALocalizeManager.shared.passByBlockPressed({(key: String) in
return NSLocalizedString(key, comment: "") // <— use preferred localization method
})

4. Release for production from manual translation maps in **Objective-C**
```objective-c
#import "QALocalize/QALocalize-Swift.h"

QALocalizeManager.shared.mode = QALocalizeModeProduction;
QALocalizeManager.shared.source = QALocalizeSourceManual;
[QALocalizeManager.shared addManualLocalizationWithMap:@{@"keyUser":@"User", @"keyPassword": @"Password"} for:@"en"];  
[QALocalizeManager.shared passByBlockPressed:^(NSString *key) {
        return L(key); // <--- use preferred localization method
    }];

Licence

QALocalize is created by Marcin Bieda and released under a MIT Licence.

Latest podspec

{
    "name": "QALocalize",
    "version": "0.9.3",
    "summary": "iOS Swift framework supporting quality assurance tests of the app with different localizations.",
    "description": "QALocalize helps developer / tester to instantly find issues in the layout related to random lengths of strings in different languages.",
    "homepage": "https://github.com/mbieda/QALocalize",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "mbieda",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/mbieda/QALocalize.git",
        "tag": "0.9.3"
    },
    "source_files": [
        "QALocalize/*.swift",
        "QALocalize/*.storyboard"
    ],
    "requires_arc": true,
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This