←Select platform

SupportsEnablingMultipleLanguages Property

Summary
Gets a value to indicate whether this engine supports enabling multiple languages at the same time.
Syntax
C#
C++/CLI
Java
Python
public bool SupportsEnablingMultipleLanguages { get; } 
public boolean getSupportsEnablingMultipleLanguages() 
property bool SupportsEnablingMultipleLanguages { 
   bool get(); 
} 
SupportsEnablingMultipleLanguages # get  (IOcrLanguageManager) 

Property Value

True it this engine supports enabling multiple languages at the same time; otherwise it is false.

Remarks

Some of the OCR engines supported by LEADTOOLS do not allow enabling more than one engine at a time. To check if the OCR engine supports more than one language, you must first check the value of the SupportsEnablingMultipleLanguages property. If the value of this property is false, then only the first item in the array passed to EnableLanguages will be used.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
 
public void OcrLanguageManagerExample() 
{ 
   // Create an instance of the engine 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Show languages supported by this engine 
      string[] supportedLanguages = ocrEngine.LanguageManager.GetSupportedLanguages(); 
 
      Console.WriteLine("Supported languages:"); 
      foreach (string supportedLanguage in supportedLanguages) 
      { 
         // Get the friendly name of this language using the .NET CultureInfo class 
         CultureInfo ci = new CultureInfo(supportedLanguage); 
         Console.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName); 
      } 
 
      // Check if current culture info language is supported 
      CultureInfo currentCulture = CultureInfo.CurrentCulture; 
      string name = currentCulture.TwoLetterISOLanguageName; 
      bool supported = ocrEngine.LanguageManager.IsLanguageSupported(name); 
      if (!supported) 
      { 
         name = currentCulture.Name; 
         supported = ocrEngine.LanguageManager.IsLanguageSupported(name); 
      } 
 
      if (supported) 
      { 
         Console.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName); 
         ocrEngine.LanguageManager.EnableLanguages(new string[] { name, "de" }); 
 
         // If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages 
         // will always return an array of 1, make a note of this 
         if (!ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages) 
            Console.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used"); 
 
         string[] enabledLanguages = ocrEngine.LanguageManager.GetEnabledLanguages(); 
         Console.WriteLine("Current enabled languages in the engine are:"); 
         foreach (string enabledLanguage in enabledLanguages) 
         { 
            // Get the friendly name of this language using the .NET CultureInfo class 
            CultureInfo ci = new CultureInfo(enabledLanguage); 
            Console.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName); 
         } 
      } 
      else 
         Console.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName); 
 
      ocrEngine.Shutdown(); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import java.util.ArrayList; 
import java.util.Locale; 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.ocr.*; 
 
 
public void OcrLanguageManagerExample() { 
   String OcrLEADRuntimeDir = "C:\\LEADTOOLS22\\Bin\\Common\\OcrLEADRuntime"; 
 
   // Create an instance of the engine 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
 
   // Start the engine using default parameters 
   ocrEngine.startup(null, null, null, OcrLEADRuntimeDir); 
 
   // Show languages supported by this engine 
   ArrayList<String> supportedLanguages = ocrEngine.getLanguageManager().getSupportedLanguages(); 
 
   System.out.println("Supported languages:"); 
   for (String supportedLanguage : supportedLanguages) { 
      // Get the friendly name of this language using the .NET CultureInfo class 
      Locale locale = new Locale(supportedLanguage); 
      System.out.printf("  %s %s\n", supportedLanguage, locale.getDisplayLanguage()); 
   } 
 
   // Check if current culture info language is supported 
   Locale currentCulture = Locale.getDefault(); 
   String name = currentCulture.getLanguage(); 
   System.out.println(name); 
   boolean supported = ocrEngine.getLanguageManager().isLanguageSupported(name); 
   if (!supported) { 
      name = currentCulture.getDisplayName(); 
      supported = ocrEngine.getLanguageManager().isLanguageSupported(name); 
   } 
 
   if (supported) { 
      System.out.printf( 
            "Current culture is %s, and it is supported by this OCR engine. Enabling only this language and German now\n", 
            currentCulture.getDisplayLanguage()); 
      ocrEngine.getLanguageManager().enableLanguages(new String[] { name, "de" }); 
 
      // If this engine does not support enabling multiple languages (currently the 
      // LEADTOOLS Advantage OCR engine), then GetEnabledLanguages 
      // will always return an array of 1, make a note of this 
      if (!ocrEngine.getLanguageManager().isSupportsEnablingMultipleLanguages()) { 
         System.out.println( 
               "This engine supports enabling only one language at a time, so only the first language we enabled will be used"); 
      } 
 
      String[] enabledLanguages = ocrEngine.getLanguageManager().getEnabledLanguages(); 
      System.out.println("Current enabled languages in the engine are:"); 
      for (String enabledLanguage : enabledLanguages) { 
         // Get the friendly name of this language using the .NET CultureInfo class 
         Locale locale = new Locale(enabledLanguage); 
         System.out.printf("  %s %s\n", enabledLanguage, locale.getDisplayLanguage()); 
      } 
   } else { 
      System.out.printf("Current culture is %s, and it is not supported by this OCR engine", 
            currentCulture.getDisplayLanguage()); 
   } 
 
   ocrEngine.dispose(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.4.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.