Skip to content

Localization

The ComPDFKit SDK for Flutter comes with the following built-in languages:

  • English(en)
  • Chinese Simplified (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 language support:

  1. Create a app/src/main/res/values-fr directory in your project, and create a strings.xml file within it.

  2. Copy the content from the link above into your strings.xml file.

guides-flutter-android-3.4.6-1
  1. Translate the strings into French. For example:

Original content:

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

Translate it to French and replace the original content:

xml
<string name="tools_document_info">Informations du document</string>

Switch your device to French, and after running your project, you will see the translated content:

guides-flutter-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-flutter-ios-3-4-6-1
  2. Here, we'll use adding French as an example, as shown below:

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

    guides-flutter-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

    guides-flutter-ios-3-4-6-4
  2. Select Localizable.strings , click on Localize in the File inspection (right-side file inspector) in Xcode. The purpose is to choose the language we want to localize, as shown below:

    Note: Before clicking on Localize, make sure that we have already added the languages for localization. This is the step where we configure the languages for internationalization (Steps: project->Info->Localizations, then click '+', add the desired languages for internationalization/localization).

    guides-flutter-ios-3-4-6-5
  3. After clicking on Localize, a dialog will appear. Expand the dialog list, and you will find that the dropdown list shows the languages we configured for internationalization above. Choose the language we want to localize, then click the 'Localize' button in the dialog, as shown below:

    guides-flutter-ios-3-4-6-6
  4. Next, check French and English, as shown below:

    guides-flutter-ios-3-4-6-7

  5. 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-flutter-ios-3-4-6-8

  6. 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-flutter-ios-3-4-6-9