Active Query Builder support area

Loading and selecting language in run-time

Last modified:


You can localize Active Query Builder by selecting a language from the list of available languages. If you can not find your language on this list, you can localize the component by yourself and load your language from the custom language file.

Selecting a language in WinForms and WPF .NET Edition 3.x (C#):

 
    // How to load a language from an external source:
 
    // load language from specified file
    ActiveQueryBuilder.Core.Helpers.Localizer.LoadLanguageFromFile(string languageFile);
    // load language from a XML string
    ActiveQueryBuilder.Core.Helpers.Localizer.LoadLanguageFromString(string xmlString);
    // load language from a stream containing an XML string
    ActiveQueryBuilder.Core.Helpers.Localizer.LoadLanguageFromStream(Stream languageStream);
 
    // How to get a list of available languages:
    foreach (string lng in ActiveQueryBuilder.Core.Helpers.Localizer.Languages)
    {
        Trace.WriteLine(lng);
    }
 
    // The language list always contains "Auto" and "Default" strings.
    // - "Auto" means the language will be detected automatically according to CultureInfo specified for 
    //   UI culture of the current thread (System.Threading.Thread.CurrentThread.CurrentUICulture).
    // - "Default" means usage of default strings containing in embedded resources.
 
    // How to set current language:
    queryBuilder1.Language = "es-MX";
    // If specified language doesn't exist, Localizer will try to fallback to the base language ("es")
    // If it doesn't exist too, the Localizer will use the "Default" language.

Selecting a language in the ASP.NET Edition 3.x:

To get the list of available languages, use the code for WinForms .NET Edition on the previous tab.

Use the QueryBuilderControl.Language property to specify the language for the control. Having set this property to "Auto", the component detects language automatically according to the "Accept-Language" HTTP request header.

Selecting a language in the VCL Edition (Delphi):

 
     // use this unit to get access to acQBLanguageManager global object
     uses acQBLocalizer;
 
     // show languages
     for i:=0 to acQBLanguageManager.LanguagesCount-1 do
     begin
         ShowMessage(acQBLanguageManager.Language[i].LanguageName);
     end;
 
     // set built-in default language
     acQBLanguageManager.CurrentLanguageIndex := -1;
 
     // set language #0
     acQBLanguageManager.CurrentLanguageIndex := 0;
 
     // load and apply custom language from file (lng is integer)
     lng := acQBLanguageManager.AddLanguageFromFile('MyLanguage', 'MyLang.lng');
     acQBLanguageManager.CurrentLanguageIndex := lng;
 
     // load and apply language from resource 
     // (lng is integer, MyLang is resource name, LANGUAGES is resource type)
     lng := acQBLanguageManager.AddLanguageFromResource('MyLanguage', 'MyLang', 'LANGUAGES');
     acQBLanguageManager.CurrentLanguageIndex := lng;
 
     // load and apply language from string (lng is integer, sLanguage is string)
     lng := acQBLanguageManager.AddLanguageFromString('MyLanguage', sLanguage);
     acQBLanguageManager.CurrentLanguageIndex := lng;
 
     // load and apply language from TStrings (lng is integer, ssLanguage is TStrings)
     lng := acQBLanguageManager.AddLanguageFromStrings('MyLanguage', ssLanguage);
     acQBLanguageManager.CurrentLanguageIndex := lng;

Selecting a language in the ActiveX Edition (Visual Basic):

 
    ' show languages
    For i = 0 To ActiveQueryBuilderX1.Localizer.Count - 1
        MsgBox "Language #" + Str(i) + ": " + ActiveQueryBuilderX1.Localizer.LanguageName(i)
    Next i
 
    ' set built-in default language
    ActiveQueryBuilderX1.Localizer.CurrentLanguage = -1
 
    ' set language #0
    ActiveQueryBuilderX1.Localizer.CurrentLanguage = 0
 
    ' load and apply custom language from file
    lng = ActiveQueryBuilderX1.Localizer.AddLanguageFromFile("MyLanguage", "MyLang.lng")
    ActiveQueryBuilderX1.Localizer.CurrentLanguage = lng
 
    ' load and apply custom language from string (sLanguage is string)
    lng = ActiveQueryBuilderX1.Localizer.AddLanguageFromString("MyLanguage", sLanguage)
    ActiveQueryBuilderX1.Localizer.CurrentLanguage = lng

Selecting a language in the ActiveX Edition (C#):

    // show languages
    for (int i = 0; i < axActiveQueryBuilderX1.Localizer.Count; ++i)
    {
        MessageBox.Show("Language #" + i.ToString() + ": " + 
        axActiveQueryBuilderX1.Localizer.get_LanguageName(i));
    }
 
    // set built-in default language
    axActiveQueryBuilderX1.Localizer.CurrentLanguage = -1;
 
    // set language #0
    axActiveQueryBuilderX1.Localizer.CurrentLanguage = 0;
 
    // load and apply custom language from file
    int lng = axActiveQueryBuilderX1.Localizer.AddLanguageFromFile("MyLanguage", "MyLang.lng");
    axActiveQueryBuilderX1.Localizer.CurrentLanguage = lng;
 
    // load and apply custom language from string (sLanguage is string)
    int lng = axActiveQueryBuilderX1.Localizer.AddLanguageFromString("MyLanguage", sLanguage);
    axActiveQueryBuilderX1.Localizer.CurrentLanguage = lng;

Selecting a language in the Java Edition:

 
    // How to load a language from an external source:
 
    // load language from specified file
    com.adbs.utils.Helpers.localizer.loadLanguageFromFile(String languageFile);
    // load language from a XML string
    com.adbs.utils.Helpers.localizer.loadLanguageFromString(String xmlString);
    // load language from a stream containing an XML string
    com.adbs.utils.Helpers.localizer.loadLanguageFromStream(InputStream languageStream);
 
    // How to get a list of available languages:
    for (String lng : com.adbs.utils.Helpers.localizer.languages)
    {
        System.out.println(lng);
    }
 
    // The language list always contains "Auto" and "Default" strings.
    // - "Auto" means the language will be detected automatically according to information
    // from java.util.Locale.getDefault()
    // - "Default" means usage of default (English) strings containing in embedded resources.
 
    // How to set current language:
    queryBuilder1.setLanguage("es-MX");
    // If specified language doesn't exist, Localizer will try to fallback to the base language ("es")
    // If it doesn't exist too, the Localizer will use the "Default" language.

This article was helpful for 1 person. Is this article helpful for you?