Softlation 1.0.2

Softlation 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年4月

Softlation团队维护。



Softlation iOS SDK

目录

概述

Softlation的libSoftlation是一个预编译的通用库,提供了一种简单的方式来实现本地化更新,并提高您的应用的质量保证和A/B测试过程。如果您想在您的应用中使用Softlation SyncSoftlation QA,则需要将库包含在您的应用中。请使用Pods或下载最新的SoftlationSDK.dmg,这些压缩文件包含支持armv7/armv7s/arm64/i386/x86_64版本的预编译通用库,并可与iOS6+一起使用。

与库一起工作

通过Pod安装

  • 创建或打开Podfile并添加您的依赖项
pod 'Softlation', '~> 1.0'
  • 在您的项目目录中运行`$ pod install`。

通过复制libSoftlation文件安装

下载并解压最新的libSoftlation版本。将“SoftlationSDK”目录复制到您的项目中

cp -r SoftlationSDK /YourProject/

此外,您需要在源文件中包含Softlation.h

快速开始

先决条件

在开始之前,您必须执行上述步骤。

Softlation同步集成

要启用Softlation Sync通知,您需要按照以下简单步骤操作

  • 将以下导入定义添加到AppDelegate.m文件。
#import "Softlation.h"
  • 将以下代码添加到didFinishLaunchingWithOptions函数中。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Your other application code.....

    // We've recommend to implement Softlation Library right before the end of the method.

    // Set YES to enable QA Mode. Default is NO 
    // Please read below how to enable QA Mode for all your controllers with NSLocalizedString
    [Softlation setQAMode:NO];

    // Optionally, you can specify custom Launch Image that will be presented right after system launch Image. 
    // The second variable holds existed Launch Image during Softlation Sync which make Sync process smooth.
    [Softlation setCustomLaunchImage:(nil) holdLaunchImageWhileLoading:YES];

    // Here you should set up your API KEY of the app on Softlation Service.
    [Softlation configureWithToken:@"API_KEY" completionHandler:nil];

    return YES;
}
  • 使用给定的Softlation API Key配置API_KEY

启用QA模式 [PRO]

如果您在其应用程序代理中设置 [Softlation setQAMode:YES]; 来使 QA 模式 工作的话,您还需要实现所有控制器中的额外方法,并使用 NSLocalizedString

  • 请将以下方法添加到所有更新字符串的视图控制器中。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(handleTranslationUpdated:)
                                                     name:kSoftlationTranslationUpdatedNotification object:nil];
    }
    return self;
}

- (void)handleTranslationUpdated:(NSNotification *)notification {
    // Update view texts, for details see below
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
  • 为控制器添加新方法

如果您在控制器中有一个表格,请简单修改以下方法

- (void)handleTranslationUpdated:(NSNotification *)notification {

    // This line you need only if your controller consist Table View with NSLocalizedString, 
    // Add it for all your Table View using their names
    // By default you can set it to tableView
    [self.TABLEVIEWNAME reloadData];

}
  • 如果您想更新表格视图外的其他 NSLocalizedString,您需要在 handleTranslationUpdated 中调用 [self.view setNeedsLayout],并在 viewWillLayoutSubviews 中简单地重置值。
- (void)handleTranslationUpdated:(NSNotification *)notification {

    [self.view setNeedsLayout];

}

- (void)viewWillLayoutSubviews {

    [super viewWillLayoutSubviews];

    self.label1.text = NSLocalizedString(@"StringNameKey", nil);
    self.label2.text = NSLocalizedString(@"StringName2Key", nil);

}

如果您在 @properties 中没有存储子视图的引用,您应该单独处理这些情况,可能需要重新创建这样的子视图以重置文本。

许可证和版权

Softlation © 2014-2016 版权所有

未经授权的复制或使用是违反适用法律的。