How to: Choose the language of the components
Show the designers, messages, error descriptions, and screen reader names of the WKL components in one language for every user of an application, whatever language their Office uses.
Requires WKL Forms Object Library 1.54 or later.
Solution overview
The components are available in English, German, Slovenian, Croatian, and Italian. Each database chooses its language; the first match wins:
- the language of the application model (
WklApplication, keylanguage); - the user interface language of Office (
Application.LanguageSettings.LanguageID(msoLanguageIDUI)); - the user interface language of Windows;
- English.
A language outside the five is skipped, so a French Office falls through to Windows and then to
English. Without a model, the components follow Office, as Access itself does; a model with
language sets the language for the application.
When the application has texts of its own (How to: Localize an application), its texts take the first of these languages they exist in, in any language, and the components speak that language whenever it is one of their five: with a Slovenian Office, a German Windows and an application with German texts only, the application and the components appear in German.
Implementation
In the application designer (Database Tools › Add-Ins › WKL Application Designer), on the General page, in the Language of the components card, choose a language, or choose Automatic (Office, Windows) to leave the choice to Office and Windows, and then click OK.
In code, in the model you save with WklApplication.Save:
Dim app As Object
Set app = CreateObject("WklForms.Application")
Debug.Print app.Save("{ ""version"": 1, ""title"": ""Customers"", ""language"": ""en"" }")
In a project built with the build tool, the key language belongs to the application model file
that appModel in access-app.json names.
Remarks
- Codes:
en,de,sl,hr,itfor the components; the model may name any language code in lower case (fr,pl) for the texts of the application, and the components then keep the order above. A regional code such asde-ATcounts as its language;Checkrefuses a value that is no language code. - When it takes effect:
Savereads the language again immediately; windows that are already open (a designer, a form with a WKL control) keep their texts until they're opened again. - For one session:
WklTexts.Languagesets a language until Access ends, ahead of the model, Office, and Windows - for example to run a test in Slovenian on a German Office. An empty text returns to the order above. - Texts of the application appear through
WklTextsin the language chosen above; see How to: Localize an application. - Error numbers don't change with the language; only
Err.Descriptiondoes. CompareErr.Numberin code, never the text. - Formats aren't affected: dates, numbers, and the names of months and days follow the Windows regional settings, as everything Access formats does.
- IntelliSense (the descriptions in the object browser and the VBA editor) stays in English in every language, because VBA reads it from the type library, which exists only once.
- Excel and Word UserForms have no application model and no Access: there the components follow the user interface language of Windows, then English; the texts of the application come from the language folder that
WklTexts.Foldernames. - WKL Office JSON in the same Access instance uses the language the components chose, once a WKL component has run in the database; before that, it follows Windows.
- Built-in symbol names (
ImageField,DefaultImage) are English in every language; the designer shows them translated. The German names are accepted as well. Names in a German Access. This documentation uses the names of VBA; a German Access shows its own properties and menus in German, and the designers show the language the components chose. The names that occur most:
In this documentation (VBA) In a German Access or designer property sheet, tab Other / Event / Data Eigenschaftenblatt, Register Andere / Ereignis / Daten ControlSource(Control Source)Steuerelementinhalt RecordSourceof a formDatensatzquelle RecordSourceof a WKL control (designer page “Data source”)Datenherkunft LinkChildFields,LinkMasterFieldsVerknüpfen von, Verknüpfen nach HasModuleEnthält Modul Enabled,Locked,TabStopAktiviert, Gesperrt, In Reihenfolge AllowEdits,AllowAdditions,AllowDeletionsBearbeitungen zulassen, Anfügen zulassen, Löschen zulassen Custom [...](opens the designer)Benutzerdefiniert design view, form view Entwurfsansicht, Formularansicht Tools › References (VBA editor) Extras › Verweise