How to change Localization settings with Foxit PDF SDK for iOS
Foxit PDF SDK for iOS Localization Feature
Foxit PDF SDK for iOS now allows users to customize the UIExtensions project language by themselves through localization files. In this article, we will show you how to achieve that functionality. Currently, our SDK comes with English, Chinese and Korean language files by default. Please follow the steps below to add your own localization settings to the UIExtension for your application.
Creating your own localization file in UIExtensions project
- Open the UIExtension project in Foxit PDF SDK for iOS directory ‘libs\uiextensions_src\uiextensions.xcodeproj’
- Select the “uiextensions project under ‘PROJECT’ and click on the “Info” tab as below:
- Under “Localizations” press the “+” sign and select the language you wish to have supported. In this tutorial, we will create a Spanish language localization file.
- The localized file will be generated to libs\uiextensions_src\UIExtensions\Resource\FoxitLocalizable\(abbreviated-language).lproj
- Locate the file and change the value of each string on the right to the language you wish to support. For example, the line says ‘”KSuccess” = “Success”‘ will be translated into “kSuccess” = “Éxito” as seen below.
Note: Using translator services online and copying+pasting content may lead to incorrect characters and syntax on your .strings file. Please be careful when moving the strings across for special characters (‘/n’,’%’,”/Save/”) that might cause your application strings to be incorrectly formatted or even not able to build the project.
- Build the UIExtension project
If the build is successful, that means your UIExtensions project now has a Spanish language localization file. The next section will show how to add that into the sample project Foxit PDF SDK offers and see the new language in action.
Implement localization file on Foxit PDF SDK for iOS Sample Project
Now that the UIExtensions library has been updated with the language file you wish to use, you will run the sample ‘complete_pdf_viewer‘ demo and see the change effects into a real-time mobile PDF viewer. Follow the steps below:
- Open the ‘complete_pdf_viewer‘ project inside your Foxit PDF SDK for iOS folder
- Make sure that the uiextensionDynamic.framework is linked under your app project “Embedded Binaries” correctly. If not, please update your project accordingly with the new uiextensionDynamic.framework. Embedded Binaries are located under your project file as below:
- In your Application project in Xcode go to “Project Navigator”, select ‘complete_pdf_viewer‘ listed under “PROJECT” and click on the “Info” tab
- Under “Localizations” press the “+” sign and select the language you wish to have supported
- For the reference files, just select the FoxitLocalizable.strings file. Uncheck the rest. Click Finish to create the file.
- If you get a message that says “FoxitLocalizable.strings” couldn’t be copied to “xx.lproj” because an item with the same name already exists, go to where the file exists. Copy that file to a temporary location. Repeat previous steps. Note: This step is to correctly reference the file.
- Copy the libs\uiextensions_src\UIExtensions\Resource\FoxitLocalizable\xx.lproj to the location where xx.lproj project was created. This copy is to make sure that the xx.lproj has the same localization content.
- Go to your iOS device settings and change the device language to the language you chose to localize.
- Build and push your application to the device. You will be able to see the language of the application is now displayed in Spanish.
For additional information on localization on iOS devices, please refer to the Apple Developer Guide here.