Skip to content
Guides

Localization

The ComPDFKit React Native SDK supports the following languages by default:

  • English (en)
  • Simplified Chinese (zh-Hans)

Adding Additional Localization to ComPDFKit

Android Platform

You can add additional translations by putting them into the res/strings-XX directory of your app. Android will automatically merge all string resources at build time. You can also override ComPDFKit strings of existing languages by putting them into the respective string folders.

Tip: To view a list of all available ComPDFKit string resources, copy them to your project from the following URL:

strings.xml

Here’s an example of adding French support:

  1. Create a app/src/main/res/values-fr directory in your project and create a strings.xml file in that directory.
  2. Copy the content from the link above into the strings.xml file.
guides-rn-android-3.4.6-1
  1. Translate the strings in the file to French. For example:

Original content:

xml
<string name="tools_document_info">Document Info</string>

Translated to French:

xml
<string name="tools_document_info">Informations du document</string>
  1. Switch your device to French, run the project, and you will see the translated content:
guides-rn-android-3.4.6-2

iOS Platform

Configure the languages that require internationalization

  1. Open your Flutter project's iOS project using Xcode.Then, Select project -> Info -> Localizations, then click '+', add the desired language for internationalization/localization, as shown below (Make sure to check 'Use Base Internationalization' by default):

    guides-rn-ios-3-4-6-1
  2. Here, we'll use adding French as an example, as shown below:

    guides-rn-ios-3-4-6-2
  3. Pop up the following dialog, and click 'Finish' directly, as shown below:

    guides-rn-ios-3-4-6-3

Internationalizing the application name

Internationalizing the application name refers to displaying different names for the same app in various language environments (i.e., the language settings on the mobile device).

  1. Creating Localizable.strings file

  2. Select Localizable.strings , click on Localize in the File inspection (right-side file inspector) in Xcode. Next, check French and English, as shown below:

    guides-rn-ios-3-4-6-7
  3. Then open the ComPDFKit Flutter iOS Demo, find the Localizable (English) file, select all the text, copy it, and paste it into the Localizable (English) file you created.

    guides-rn-ios-3-4-6-8
  4. Finally, select the Localizable (French) file and configure the corresponding French translations according to the Localizable (English) file, ensuring that the number of text segments in both files is the same. For example, if the Localizable (English) file has "Viewer" = "Viewer";, the Localizable (French) file should have the corresponding "Viewer" = "Téléspectatrice";.

    guides-rn-ios-3-4-6-9