VintaSoft Imaging .NET SDK 12.5: Documentation for Web developer
In This Topic
    Localize the web DICOM viewer
    In This Topic
    VintaSoft ASP.NET Core DICOM Viewer Demo provides the localization dictionaries, which allow to localize the web DICOM viewer (WebDicomControlJS) into 45 languages (Afrikaans, Arabic, Armenian, Azerbaijan, Belarusian, Bulgarian, Chinese, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, Georgian, German, Greece, Hebrew, Hindi, Hungarian, Italian, Japanese, Kazakh, Korean, Kyrgyz, Latvian, Lithuanian, Norwegian, Portugese, Romanian, Russian, Slovakian, Slovenian, Spanish, Swahili, Swedish, Tajik, Tatar, Turkish, Turkmen, Ukrainian, Uzbek, Vietnamese, Zulu).

    The localization dictionaries can be found in the "<SdkInstallPath>\VintaSoft\Imaging .NET v12.5\Examples\ASP.NET Core\CSharp\AspNetCoreDicomViewerDemo\wwwroot\locales\" folder.

    If you want to create a custom localization dictionary for the user interface of web DICOM viewer, you should do the following steps:
    1. Define the list of languages for localization
    2. Create dictionaries for localization
    3. Add JavaScript code for UI localization

    If you have created the custom localization dictionary for web DICOM viewer and you want to share your dictionary with other users, please send us the created custom dictionary and we will include it into the source codes of VintaSoft ASP.NET Core DICOM Viewer Demo.


    1. Define the list of languages for localization

    First, it is necessary to define the list of languages for localization and create a file of localization settings, for example "settings.json". Here is the content of file "settings.json", which defines that the interface can be localized to English and German languages:
    {
      "locales": [ "en", "af", "ar", "bg", "cs", "da", "de", "el", "es", "fi", "fr", "he", "hi", "hr", "hu", "it", "ja", "ko", "nb", "nl", "pt", "ro", "ru", "sv", "tr", "vi", "zh" ]
    }
    

    Next, the "settings.json" file must be added to the content of web application, for example placed into folder "locales".

    Finally, it is necessary to add the element "link" with information about localization settings onto a web page:
    <link rel="localization" href="/locales/settings.json">
    


    2. Create dictionaries for localization

    The dictionary file should have a name, which equals to the browser locale name, and ".txt" extension. For example, the file of English language dictionary must have the name "en.txt", the file of German language dictionary must have the name "de.txt", the file of French language dictionary must have the name "fr.txt", the file of Spanish language dictionary must have the name "es.txt", the file of Italian language dictionary must have the name "it.txt", the file of Portuguese language dictionary must have the name "pt.txt", the file of Russian language dictionary must have the name "ru.txt".

    The dictionary file should be located in the same folder with the file "settings.json", in our case this folder is "locales".

    For creating English dictionary it is necessary to do the following steps: Here is JavaScript code that demonstrates how to create the localization dictionary for a HTML page that contains web DICOM viewer:
    ...
    // create UI localizer
    _localizer = new Vintasoft.Shared.VintasoftLocalizationJS();
    ...
    
    /**
     Creates the dictionary for localization of application UI.
    */
    function __createUiLocalizationDictionary() {
        var tempDialogs = [];
        __createDicomViewerDialogsForLocalization(tempDialogs);
    
        if (_localizer == null)
            // create UI localizer
            _localizer = new Vintasoft.Shared.VintasoftLocalizationJS();
    
        var localizationDict = _localizer.getDocumentLocalizationDictionary();
        var localizationDictString = JSON.stringify(localizationDict, null, '\t');
        console.log(localizationDictString);
    
        var floatingContainer = document.getElementById("dicomControlContainer");
        for (var i = 0; i < tempDialogs.length; i++) {
            floatingContainer.removeChild(tempDialogs[i].get_DomElement());
            delete tempDialogs[i];
        }
    }
    
    /**
     Creates the dialogs, which are used in DICOM control, for localization.
    */
    function __createDicomViewerDialogsForLocalization(tempDialogs) {
        var floatingContainer = document.getElementById("dicomControlContainer");
    
        var dicomViewerControl = _dicomControl.get_DicomViewerControl();
    
        var dicomMetadataDialog = new Vintasoft.Imaging.Dicom.Dialogs.WebUiDicomMetadataDialogJS(dicomViewerControl);
        dicomMetadataDialog.render(floatingContainer);
        tempDialogs.push(dicomMetadataDialog);
    
        var customDicomVoiLutDialog = new Vintasoft.Imaging.Dicom.Dialogs.WebUiCustomDicomVoiLutDialogJS(dicomViewerControl);
        customDicomVoiLutDialog.render(floatingContainer);
        tempDialogs.push(customDicomVoiLutDialog);
    }
    
    


    For creating German (or other non English) dictionary it is necessary to do the following steps:
    Here is an example of simple dictionary file:
    {
            "dicomViewerControl": {
                    "fileLabel": {
                            "text": "File"
                    },
                    "viewLabel": {
                            "text": "View"
                    },
                    "toolsLabel": {
                            "text": "Tools"
                    },
                    "measurementsLabel": {
                            "text": "Measurements"
                    },
                    "uploadDicomFilesButton": {
                            "title": "Upload and open DICOM files"
                    },
                    "closeFilesButton": {
                            "title": "Close files"
                    },
                    "clearSessionCacheButton": {
                            "title": "Clear session cache"
                    },
                    "showDicomFileMetadataButton": {
                            "title": "Show DICOM File Metadata"
                    },
                    "showMobileMenuButton": {
                            "title": "More"
                    },
                    "zoomOutButton": {
                            "title": "Zoom out"
                    },
                    ...
            }
    }
    


    3. Add JavaScript code for UI localization

    The VintasoftLocalizationJS class provides functionality for localization of DOM elements and constant strings.

    Here is JavaScript code that demonstrates how to enable localization of web DICOM viewer in web application:
    /**
     Enables the localization of application UI.
    */
    function __enableUiLocalization() {
        if (_localizer == null)
            // create UI localizer
            _localizer = new Vintasoft.Shared.VintasoftLocalizationJS();
    
        // if localizer is ready (localizer loaded localization dictionary)
        if (_localizer.get_IsReady()) {
            // localize DOM-elements of web page
            _localizer.localizeDocument();
        }
        // if localizer is NOT ready
        else
            // wait when localizer will be ready
            Vintasoft.Shared.subscribeToEvent(_localizer, "ready", function () {
                // localize DOM-elements of web page
                _localizer.localizeDocument();
            });
    
        // subscribe to the "dialogShown" event of web spreadsheet document editor
        Vintasoft.Shared.subscribeToEvent(_dicomControl, "dialogShown", function (event, data) {
            _localizer.localizeDocument();
        });
    }