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:
Here’s an example of adding French support:
- Create a
app/src/main/res/values-fr
directory in your project and create astrings.xml
file in that directory. - Copy the content from the link above into the
strings.xml
file.

- Translate the strings in the file to French. For example:
Original content:
<string name="tools_document_info">Document Info</string>
Translated to French:
<string name="tools_document_info">Informations du document</string>
- Switch your device to French, run the project, and you will see the translated content:

iOS Platform
Configure the languages that require internationalization
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):
Here, we'll use adding French as an example, as shown below:
Pop up the following dialog, and click 'Finish' directly, as shown below:
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).
Creating
Localizable.strings
fileSelect
Localizable.strings
, click on Localize in the File inspection (right-side file inspector) in Xcode. Next, check French and English, as shown below:Then open the ComPDFKit Flutter iOS Demo, find the
Localizable (English)
file, select all the text, copy it, and paste it into theLocalizable (English)
file you created.Finally, select the
Localizable (French)
file and configure the corresponding French translations according to theLocalizable (English)
file, ensuring that the number of text segments in both files is the same. For example, if theLocalizable (English)
file has"Viewer" = "Viewer";
, theLocalizable (French)
file should have the corresponding"Viewer" = "Téléspectatrice";
.