Skip to main content
Language:

Localization

VideoEditor SDK can easily be localized for your target audience.

We provide an English fallback localization, that will be used when no matching localization is found. To determine the matching language, VideoEditor SDK uses NSLocale.preferredLanguages. To add support for a language, please refer to Apple's localization guidelines. We also provide two properties to customize your localization, VESDK.localizationDictionary and VESDK.localizationBlock.

localizationDictionary#

The first way to add another language is to set VESDK.localizationDictionary to a dictionary containing your localization. The key of the dictionary needs to be the locale that you want to add, the value should be another dictionary containing the localization keys and the corresponding localized strings as values. All available localization keys are defined in the Localizable.strings file.

localizationDictionary#

The more advanced way to add localization is passing a closure, which will be called for each string that can be localized. You can then use that closure to look up a matching localization in your app's localizationBlock or do something completely custom.

Localizable.strings#

A list of strings that are used in the SDK is available within the framework's bundle at ImglyKit.framework/ImglyKit.bundle/en.lproj/Localizable.strings. The contents of that file are in binary format. To convert them back into a readable format please use the following command:

plutil -convert xml1 ImglyKit.framework/ImglyKit.bundle/en.lproj/Localizable.strings
File:
import UIKit
import VideoEditorSDK
class VideoLocalizationSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
// Create a `Video` from a URL to a video in the app bundle.
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
// The default option to localize the editor is to use a `Localizable.strings`
// file containing the localization keys and the corresponding localized
// strings as values.
// For further reference, please take a look at the official guides by
// Apple: https://developer.apple.com/documentation/Xcode/localization
// Another way to localize the editor is to provide a custom localization
// dictionary. The key of the dictionary needs to be the locale that
// you want to add or change, the value should be another dictionary
// containing the localization keys and the corresponding localized
// strings as values.
// For this example, the editor overrides some values for the provided
// English localization.
VESDK.localizationDictionary = [
"en": [
"pesdk_transform_title_name": "Crop",
"pesdk_adjustments_title_name": "Correct",
"pesdk_adjustments_button_reset": "Clear"
]
]
// The more advanced way to add localization is passing a closure,
// which will be called for each string that can be localized.
// You can then use that closure to look up a matching localization
// in your app's `Localizable.strings` file or do something completely custom.
//
// Please note that if the `localizationBlock` and the `localizationDictionary`
// both include a localization value for the same string, the value of the
// `localizationBlock` takes precedence.
VESDK.localizationBlock = { stringToLocalize in
switch stringToLocalize {
case "pesdk_brush_title_name":
return "Draw"
case "pesdk_filter_title_name":
return "Effects"
case "pesdk_textDesign_title_name":
return "Designs"
default:
return nil
}
}
// Create and present the video editor. Make this class the delegate of it to handle export and cancelation.
let videoEditViewController = VideoEditViewController(videoAsset: video)
videoEditViewController.delegate = self
videoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(videoEditViewController, animated: true, completion: nil)
}
// MARK: - VideoEditViewControllerDelegate
func videoEditViewControllerShouldStart(_ videoEditViewController: VideoEditViewController, task: VideoEditorTask) -> Bool {
// Implementing this method is optional. You can perform additional validation and interrupt the process by returning `false`.
true
}
func videoEditViewControllerDidFinish(_ videoEditViewController: VideoEditViewController, result: VideoEditorResult) {
// The user exported a new video successfully and the newly generated video is located at `result.output.url`. Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidFail(_ videoEditViewController: VideoEditViewController, error: VideoEditorError) {
// There was an error generating the video.
print(error.localizedDescription)
// Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidCancel(_ videoEditViewController: VideoEditViewController) {
// The user tapped on the cancel button within the editor. Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
}
}