←Select platform

GetEnabledLanguages Method

Summary
Gets the names of the current enabled languages environment of the character set used by the IOcrEngine.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public string[] GetEnabledLanguages() 
@property (nonatomic, strong, readonly) NSArray<NSNumber *> *enabledLanguages 
public String[] getEnabledLanguages()  
array<String^>^ GetEnabledLanguages();  
def GetEnabledLanguages(self): 

Return Value

An array of String object that contains the names of the current enabled languages. Note: If you are using the LEADTOOLS OCR Module - LEAD Engine, this array will contain only one item that represents the currently enabled language.

Remarks

The EnableLanguages method is used to define the main part of the language environment of the character sets used by the IOcrEngine.

The default value of the enabled languages is "en" (for English).

Use the GetEnabledLanguages to obtain a list of the languages currently enabled in the language environment.

The language values used throughout the LEADTOOLS OCR toolkit is a string value based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture code associated with a country or region.

The language environment defines the character set(s) recognized by the OCR engine. For example, if you enable the English and German languages, the German characters (ä, Ä, é, ö, Ö, ü, Ü, ß) will be combined with the English characters to define the set recognized by the engine. The language environment does not perform spell checking however, for that, refer to IOcrSpellCheckManager.

Example
C#
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:\LEADTOOLS22\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Ocr Assembly

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