CodeCarvings Piczard V1.2 Help
Localizing And Customizing Texts
Send Feedback
Piczard Fundamentals - Web > PictureTrimmer > Localizing And Customizing Texts

Glossary Item Box

CONTENTS

  1. Introduction
  2. The IStaticLocalizationPlugin interface
  3. The IDynamicLocalizationPlugin interface
  4. Full example
  5. List of Localization keys

 

Please see the Example A.402 - "Customize Piczard / Localize & customize texts"

 

 

1. Introduction

Piczard is provided with 2 built-in localizations:

You can add additional translations and/or customize texts by implementing one of the two Plugin interfaces that Piczrd provides:

For more information about Piczard Plugins, please see:

The property Culture of the PictureTrimmer control allows to select which translation to use.
Accepted values are:

 

 

2. The IStaticLocalizationPlugin interface

The IStaticLocalizationPlugin interface consists of 2 methods:

You can use the LoadDictionaryFromXMLFile method to load a dictionary directly from a resource XML file.

Within the Piczard installation directory (usually "C:\Program files\CodeCarvings\Piczard V1\"), subfolder "Resources\Globalization", you may find the xml resource files relative to the Piczard default languages:

  • CodeCarvings.Piczard.en.resx.xml
  • CodeCarvings.Piczard.it.resx.xml

Please note that It is not necessary that the dictionary contains all the localization keys.
For example, if you need to translate/customize only one text, you can return a dictionary containing only 1 element.

 

 

3. The IDynamicLocalizationPlugin interface

The IDynamicLocalizationPlugin interface consists of only 1 method: GetString

This method receives 3 parameters:

Example:

Returning translated/customized texts Copy Code
public PluginOperationResult<string> GetString(string key, string culture, string tag)
{
   
string result = null;
   
if (culture == "fr")
   {
       
// Manage the "fr" culture
       
switch (key)
       {
           
case "PT_MUI_Text_Details":
               result =
"Details";
               
if (tag == "ExA402_PopupPictureTrimmer")
               {
                   result +=
" - Popup";
               }    
               
break;
           
case "PT_MUI_Text_Original":
               result =
"Source:";
               
break;
       }
   }
   
if (result != null)
   {
       
// Return the custom text
       
return base.GetHandledResult<string>(result);
   }
   
else
   {
       
// Use the default text
       
return base.GetNotHandledResult<string>();
   }
}

 

 

4. Full example

Step 1 - Develop the localization Plugin

MyDynamicLocalizationPlugin.cs Copy Code
namespace MyNamespace1
{
   
public class MyDynamicLocalizationPlugin
       : Plugin, IDynamicLocalizationPlugin
   {
       
public MyDynamicLocalizationPlugin(PluginConstructorArgs constructorArgs)
           :
base(constructorArgs)
       {
       }
       
protected override void Initialize(PluginInitializationArgs initializationArgs)
       {
       }

       
public PluginOperationResult<string> GetString(string key, string culture, string tag)
       {
           
if (culture == "it")
           {
               
// Handle the "it" culture
               
switch (key)
               {
                   
case "PT_MUI_Text_Details":
                       
return base.GetHandledResult<string>("DETTAGLI");
               }
           }

           
// Use the default text
           
return base.GetNotHandledResult<string>();
       }
   }
}

 

Step 2 - Register the Plugin in the application configuration file

web.config Copy Code
<?xml version="1.0"?>
<configuration>
 <configSections>
   <sectionGroup name=
"codeCarvings.piczard">
     <section name=
"coreSettings" type="CodeCarvings.Piczard.Configuration.CoreSettingsSectionHandler, CodeCarvings.Piczard" requirePermission="false"/>
   </sectionGroup>
 </configSections>
 <codeCarvings.piczard>
   <coreSettings>
     <plugins>
       <plugin type=
"MyNamespace1.MyDynamicLocalizationPlugin, MyAssemblyName" />
     </plugins>
  </coreSettings>
</codeCarvings.piczard>
</configuration>

 

Step 3 - Use the Plugin

MyWebPage.aspx Copy Code
<ccPiczard:InlinePictureTrimmer runat="server" ID="InlinePictureTrimmer1"
   
Culture="it" />

 

 

5. List of Localization keys

The following are the defined localization keys and their default values:

Localization key default value (en)
Web_Shared_Error_UnableToLoadResources Piczard client-side library failed to load.
Web_Shared_Error_UpgradeFlashPlayer You need to upgrade your Adobe Flash Player
PT_MUI_Text_Loading Loading image...
PT_MUI_Text_NoImageLoaded No image loaded
PT_MUI_Text_Details Details
PT_MUI_Text_ZoomView Zoom view
PT_MUI_Text_ResizeImage Resize image
PT_MUI_Text_RotateFlipImage Rotate / flip image
PT_MUI_Text_ImageAdjustments Image adjustments
PT_MUI_Text_Original Original:
PT_MUI_Text_Resized Resized:
PT_MUI_Text_Cursor Cursor:
PT_MUI_Text_WidthPrefix W
PT_MUI_Text_HeightPrefix H
PT_MUI_Text_Brightness Brightness
PT_MUI_Text_Contrast Contrast
PT_MUI_Text_Hue Hue
PT_MUI_Text_Saturation Saturation
PT_MUI_Tooltip_Original Original image size
(Width and Height) in {#uiUnit#}.
PT_MUI_Tooltip_Resized Current image size
(Width and Height) in {#uiUnit#},
using "Resize" factor: {#resizeFactor#}%.
PT_MUI_Tooltip_Cursor Actual cursor location
(from Top-Left corner) in {#uiUnit#}.
PT_MUI_Tooltip_SelectionLocation Actual selection location
(from Top-Left corner) in {#uiUnit#}.
PT_MUI_Tooltip_SelectionSize Actual selection size
(Width and Height) in {#uiUnit#}.
PT_MUI_Tooltip_Zoom Current image zoom factor.
PT_MUI_Tooltip_Zoom_Slider Dragging the cursor,
the view will change
(without changing any of the original parameters).
PT_MUI_Tooltip_Zoom_Reset Reset the current image zoom factor.
PT_MUI_Tooltip_Resize Current image resize factor.
PT_MUI_Tooltip_Resize_Slider Dragging the cursor, the image will be resized.
PT_MUI_Tooltip_Resize_Reset Reset the current image resize factor.
PT_MUI_Tooltip_Rotate Rotate image: 0°, 90°, 180°, 270°.
PT_MUI_Tooltip_FlipH Flip image horizontally.
PT_MUI_Tooltip_FlipV Flip image vertically.
PT_MUI_Tooltip_Brightness Current brightness.
PT_MUI_Tooltip_Brightness_Slider Dragging the cursor, the brightness of the image will change.
PT_MUI_Tooltip_Contrast Current contrast.
PT_MUI_Tooltip_Contrast_Slider Dragging the cursor, the contrast of the image will change.
PT_MUI_Tooltip_Hue Current hue.
PT_MUI_Tooltip_Hue_Slider Dragging the cursor, the hue of the image will change.
PT_MUI_Tooltip_Saturation Current saturation.
PT_MUI_Tooltip_Saturation_Slider Dragging the cursor, the saturation of the image will change.
PT_MUI_Tooltip_ImageAdjustments_Reset Reset every image adjustments parameter.
PT_MUI_Button_Zoom_Reset Reset
PT_MUI_Button_Resize_Reset Reset
PT_MUI_Button_ImageAdjustments_Reset Reset
PPT_Popup_Button_Save Ok
PPT_Popup_Button_Cancel Cancel

 

©2013 Sergio Turolla. All Rights Reserved.