React PDF viewer

Example: Use a different language

All text items of the viewer component are stored in a separate .json file. It allows us to localize the entire user interface in a different language easily.

By default, all text items are translated into English which is stored in the localization/en_US.json file. In order to translate it into another language, you have to translate the values of properties. The properties aren't changed.

Here are the default English version and another version which is translated into Vietnamese.

When the localized text are ready, we can pass it to the localization parameter of the viewer component:

import Viewer, { LocalizationMap } from '@phuocng/react-pdf-viewer';

// Your language
import vi_VN from './path/to/vi_VN.json';

    localization={(vi_VN as any) as LocalizationMap}

As you can see in the following example, all text items are translated and displayed in the target language:

/ 8