AWSTranslate Class Reference

Inherits from AWSService : NSObject
Declared in AWSTranslateService.h
AWSTranslateService.m

Overview

Provides translation between one source language and another of the same set of languages.

Other Methods

+ defaultTranslate

Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with defaultServiceConfiguration from [AWSServiceManager defaultServiceManager]. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

+ (instancetype)defaultTranslate

Return Value

The default service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
    AWSServiceManager.default().defaultServiceConfiguration = configuration

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                      identityPoolId:@"YourIdentityPoolId"];
      AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                           credentialsProvider:credentialsProvider];
      [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

      return YES;
  }

Then call the following to get the default service client:

Swift

 let Translate = AWSTranslate.default()

Objective-C

 AWSTranslate *Translate = [AWSTranslate defaultTranslate];

Declared In

AWSTranslateService.h

+ registerTranslateWithConfiguration:forKey:

Creates a service client with the given service configuration and registers it for the key.

+ (void)registerTranslateWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key

Parameters

configuration

A service configuration object.

key

A string to identify the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSTranslate.register(with: configuration!, forKey: "USWest2Translate")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSTranslate registerTranslateWithConfiguration:configuration forKey:@"USWest2Translate"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let Translate = AWSTranslate(forKey: "USWest2Translate")

Objective-C

 AWSTranslate *Translate = [AWSTranslate TranslateForKey:@"USWest2Translate"];

Warning: After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSTranslateService.h

+ TranslateForKey:

Retrieves the service client associated with the key. You need to call + registerTranslateWithConfiguration:forKey: before invoking this method.

+ (instancetype)TranslateForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSTranslate.register(with: configuration!, forKey: "USWest2Translate")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSTranslate registerTranslateWithConfiguration:configuration forKey:@"USWest2Translate"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let Translate = AWSTranslate(forKey: "USWest2Translate")

Objective-C

 AWSTranslate *Translate = [AWSTranslate TranslateForKey:@"USWest2Translate"];

Declared In

AWSTranslateService.h

+ removeTranslateForKey:

Removes the service client associated with the key and release it.

+ (void)removeTranslateForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSTranslateService.h

– deleteTerminology:

A synchronous action that deletes a custom terminology.

- (AWSTask *)deleteTerminology:(AWSTranslateDeleteTerminologyRequest *)request

Parameters

request

A container for the necessary parameters to execute the DeleteTerminology service method.

Return Value

An instance of AWSTask. On successful execution, task.result will be nil. On failed execution, task.error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorResourceNotFound, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– deleteTerminology:completionHandler:

A synchronous action that deletes a custom terminology.

- (void)deleteTerminology:(AWSTranslateDeleteTerminologyRequest *)request completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the DeleteTerminology service method.

completionHandler

The completion handler to call when the load request is complete. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorResourceNotFound, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– getTerminology:

Retrieves a custom terminology.

- (AWSTask<AWSTranslateGetTerminologyResponse*> *)getTerminology:(AWSTranslateGetTerminologyRequest *)request

Parameters

request

A container for the necessary parameters to execute the GetTerminology service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSTranslateGetTerminologyResponse. On failed execution, task.error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorResourceNotFound, AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– getTerminology:completionHandler:

Retrieves a custom terminology.

- (void)getTerminology:(AWSTranslateGetTerminologyRequest *)request completionHandler:(void ( ^ ) ( AWSTranslateGetTerminologyResponse *response , NSError *error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the GetTerminology service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorResourceNotFound, AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– importTerminology:

Creates or updates a custom terminology, depending on whether or not one already exists for the given terminology name. Importing a terminology with the same name as an existing one will merge the terminologies based on the chosen merge strategy. Currently, the only supported merge strategy is OVERWRITE, and so the imported terminology will overwrite an existing terminology of the same name.

If you import a terminology that overwrites an existing one, the new terminology take up to 10 minutes to fully propagate and be available for use in a translation due to cache policies with the DataPlane service that performs the translations.

- (AWSTask<AWSTranslateImportTerminologyResponse*> *)importTerminology:(AWSTranslateImportTerminologyRequest *)request

Parameters

request

A container for the necessary parameters to execute the ImportTerminology service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSTranslateImportTerminologyResponse. On failed execution, task.error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorLimitExceeded, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– importTerminology:completionHandler:

Creates or updates a custom terminology, depending on whether or not one already exists for the given terminology name. Importing a terminology with the same name as an existing one will merge the terminologies based on the chosen merge strategy. Currently, the only supported merge strategy is OVERWRITE, and so the imported terminology will overwrite an existing terminology of the same name.

If you import a terminology that overwrites an existing one, the new terminology take up to 10 minutes to fully propagate and be available for use in a translation due to cache policies with the DataPlane service that performs the translations.

- (void)importTerminology:(AWSTranslateImportTerminologyRequest *)request completionHandler:(void ( ^ ) ( AWSTranslateImportTerminologyResponse *response , NSError *error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the ImportTerminology service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorLimitExceeded, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– listTerminologies:

Provides a list of custom terminologies associated with your account.

- (AWSTask<AWSTranslateListTerminologiesResponse*> *)listTerminologies:(AWSTranslateListTerminologiesRequest *)request

Parameters

request

A container for the necessary parameters to execute the ListTerminologies service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSTranslateListTerminologiesResponse. On failed execution, task.error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– listTerminologies:completionHandler:

Provides a list of custom terminologies associated with your account.

- (void)listTerminologies:(AWSTranslateListTerminologiesRequest *)request completionHandler:(void ( ^ ) ( AWSTranslateListTerminologiesResponse *response , NSError *error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the ListTerminologies service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidParameterValue, AWSTranslateErrorTooManyRequests, AWSTranslateErrorInternalServer.

Declared In

AWSTranslateService.h

– translateText:

Translates input text from the source language to the target language. It is not necessary to use English (en) as either the source or the target language but not all language combinations are supported by Amazon Translate. For more information, see Supported Language Pairs.

  • Arabic (ar)

  • Chinese (Simplified) (zh)

  • Chinese (Traditional) (zh-TW)

  • Czech (cs)

  • Danish (da)

  • Dutch (nl)

  • English (en)

  • Finnish (fi)

  • French (fr)

  • German (de)

  • Hebrew (he)

  • Indonesian (id)

  • Italian (it)

  • Japanese (ja)

  • Korean (ko)

  • Polish (pl)

  • Portuguese (pt)

  • Russian (ru)

  • Spanish (es)

  • Swedish (sv)

  • Turkish (tr)

To have Amazon Translate determine the source language of your text, you can specify auto in the SourceLanguageCode field. If you specify auto, Amazon Translate will call Amazon Comprehend to determine the source language.

- (AWSTask<AWSTranslateTranslateTextResponse*> *)translateText:(AWSTranslateTranslateTextRequest *)request

Parameters

request

A container for the necessary parameters to execute the TranslateText service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSTranslateTranslateTextResponse. On failed execution, task.error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidRequest, AWSTranslateErrorTextSizeLimitExceeded, AWSTranslateErrorTooManyRequests, AWSTranslateErrorUnsupportedLanguagePair, AWSTranslateErrorDetectedLanguageLowConfidence, AWSTranslateErrorResourceNotFound, AWSTranslateErrorInternalServer, AWSTranslateErrorServiceUnavailable.

Declared In

AWSTranslateService.h

– translateText:completionHandler:

Translates input text from the source language to the target language. It is not necessary to use English (en) as either the source or the target language but not all language combinations are supported by Amazon Translate. For more information, see Supported Language Pairs.

  • Arabic (ar)

  • Chinese (Simplified) (zh)

  • Chinese (Traditional) (zh-TW)

  • Czech (cs)

  • Danish (da)

  • Dutch (nl)

  • English (en)

  • Finnish (fi)

  • French (fr)

  • German (de)

  • Hebrew (he)

  • Indonesian (id)

  • Italian (it)

  • Japanese (ja)

  • Korean (ko)

  • Polish (pl)

  • Portuguese (pt)

  • Russian (ru)

  • Spanish (es)

  • Swedish (sv)

  • Turkish (tr)

To have Amazon Translate determine the source language of your text, you can specify auto in the SourceLanguageCode field. If you specify auto, Amazon Translate will call Amazon Comprehend to determine the source language.

- (void)translateText:(AWSTranslateTranslateTextRequest *)request completionHandler:(void ( ^ ) ( AWSTranslateTranslateTextResponse *response , NSError *error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the TranslateText service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSTranslateErrorDomain domain and the following error code: AWSTranslateErrorInvalidRequest, AWSTranslateErrorTextSizeLimitExceeded, AWSTranslateErrorTooManyRequests, AWSTranslateErrorUnsupportedLanguagePair, AWSTranslateErrorDetectedLanguageLowConfidence, AWSTranslateErrorResourceNotFound, AWSTranslateErrorInternalServer, AWSTranslateErrorServiceUnavailable.

Declared In

AWSTranslateService.h

Other Methods

  configuration

The service configuration used to instantiate this service client.

@property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration

Discussion

Warning: Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSTranslateService.h