As of Version 7.0.0 - July 16, 2024, DocumentViewer supports 111 language files which are bundled with pdfjs project. However for some few custom text which are not inside those language files, DocumentViewer.Translations property is used to override:
documentViewer.Translations = new()
{
{
"en",
new()
{
{ "preparing-document", "Preparing document..." },
{ "cover-sheet", "Cover Sheet" },
{ "rotation-mode", "Rotation Mode" },
{ "rotation-mode-title", "Rotation Mode (rotate current page or all pages)" },
{ "full-screen", "Full Screen" },
{ "download-original", "Download Original" },
{ "any-word", "Any Word" }
}
},
{
"de",
new()
{
{ "any-word", "Jedes Wort" }
}
}
};
Translation files for main 111 languages are embedded inside DocumentUltimate's DLL.
However you can create your own translation file for a new language or update a translation file for an existing language:
- Download a viewer.ftl file to start with from pdfjs project on GitHub:
https://github.com/mozilla/pdf.js/tree/master/l10n
There is a subfolder for each language such as en-US and a viewer.ftl file inside that subfolder.
- Create this folder structure under your project's web root:
App_GlobalResources\Library\pdfjskit\pdfjs\web\locale
- Create the subfolder for your target language, the subfolder name should match the one in pdfjs project.
For example for en-US, your path will look like this:
App_GlobalResources\Library\pdfjskit\pdfjs\web\locale\en-US
- viewer.ftl files are simple text files so they are easy to edit, after customizing the file, put it under the created path like:
App_GlobalResources\Library\pdfjskit\pdfjs\web\locale\en-US\viewer.ftl
- DocumentUltimate will recognize and load your new translation file after application restart.
For ASP.NET Core:
Recycle AppPool, restart WebSite in IIS or if development machine, exit IIS Express or rebuild your project to force AppDomain restart.
For Classic ASP.NET:
Normally when you modify a file (save or create) under the special App_GlobalResources subfolder, ASP.NET will restart your web application automatically, so your new translation file will be recognized immediately. If not, you can touch Web.config (simply save) or recycle AppPool or rebuild your project to force AppDomain restart.
For older versions:
As of Version 5.7.0 - November 3, 2020, DocumentUltimate includes translations for these languages:
- English (en)
- Deutsch (de)
- français (fr)
- italiano (it)
- español (es)
- galego (gl)
- português (Brasil) (pt-BR)
- polski (pl)
- русский (ru)
- dansk (da)
- svenska (sv)
- norsk bokmål (nb)
Translation files for these languages are embedded inside DocumentUltimate's DLL.
However you can create your own translation file for a new language or update a translation file for an existing language:
- Download the latest translations files of DocumentUltimate
- Create this folder structure under your project: App_GlobalResources\WebViewer\i18n
(note that before Version 4.3.0 - October 4, 2018 the folder structure was App_GlobalResources\WebViewer\Html5\Resources\i18n)
- Copy translation-en.json file from this zip to the folder App_GlobalResources\WebViewer\i18n and rename the file according to the new language.
Translation files are named in this format: translation-cultureName.json
Make sure you use the .NET standard codes for cultures, see the Language tag column in the list of language/region names supported by Windows.
For example, the cultureName can be a specific culture like translation-de-CH.json (German in Switzerland) or a general (fallback) culture like translation-de.json (German).
- Edit this .json file with a text editor which supports UTF-8 encoding (e.g. Visual Studio, Notepad2, Notepad++). Basic Notepad only supports ANSI so it will corrupt encoding of your file so avoid it.
Translate the values for keys to the target language (e.g. values to be translated are yellow highlighted):{
"controlbar": {
"fullScreen": "Full Screen",
"download": "Download",
"downloadAsPdf": "Download as PDF",
Value "" (empty string) means the translation is missing for a key (so English one will be used)
To complete the translation of an existing translation file, search for "" and add the translated values for those keys.
After translation is completed, ensure you save the .json file with UTF-8 encoding.
- DocumentUltimate will recognize your new translation file after application restart as it's put in the special folder App_GlobalResources\WebViewer\i18n
For Classic ASP.NET:
Normally when you modify a file (save or create) under your project including App_GlobalResources subfolder, ASP.NET will restart your web application, so your new translation file will be recognized automatically. If not, you can touch Web.config (simply save) or recycle AppPool or rebuild your project to force AppDomain restart.
You can now use your new translation file via setting the DisplayLanguage property to the culture name:documentViewer.DisplayLanguage = "de-CH";
If you don’t set this property, the culture from CultureInfo.CurrentUICulture will be used by DocumentUltimate automatically.
- Please send us your completed translation file, so that we can include and embed in DocumentUltimate's DLL in the next version. This way you will not need to keep App_GlobalResources folder under your project.