Go to console

FirebaseMLNLTranslate Framework Reference

FIRTranslator


@interface FIRTranslator : NSObject

A class that translates the given input text.

  • Unavailable.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Translates the given text from the source language into the target language.

    This method will return an error if the model files have not been downloaded.

    Declaration

    Objective-C

    - (void)translateText:(nonnull NSString *)text
               completion:(nonnull FIRTranslatorCallback)completion;

    Parameters

    text

    A string in the source language.

    completion

    Handler to call back on the main queue with the translation result or error.

  • Downloads the model files required for translation, if they are not already downloaded.

    Declaration

    Objective-C

    - (void)downloadModelIfNeededWithCompletion:
        (nonnull FIRTranslatorDownloadModelIfNeededCallback)completion;

    Parameters

    completion

    Handler to call back on the main queue with an error, if any.

  • Downloads the model files required for translation when the given conditions are met. If model has already been downloaded, completes without additional work.

    Declaration

    Objective-C

    - (void)
        downloadModelIfNeededWithConditions:
            (nonnull FIRModelDownloadConditions *)conditions
                                 completion:
                                     (nonnull
                                          FIRTranslatorDownloadModelIfNeededCallback)
                                         completion;

    Parameters

    conditions

    The downloading conditions for the translate model.

    completion

    Handler to call back on the main queue with an error, if any.