How to add a new language layout to Qt Virtual Keyboard?
-
I am trying to add a new custom language layout to Qt Virtual Keyboard. As an example, I am working on adding a layout for "English (Japan)" (
en_JP
).I have referred to the documentation available at Qt Technical Guide - Keyboard Layouts. While it explains how to add custom layouts, it does not cover the process for creating layouts for an entirely new language, including how to register the new language and its layout in a clean way.
It would be very helpful if someone could clarify the complete process for adding a new language and its layout, including any steps not covered in the documentation.
Environment
• Qt 5.15 -
Hi and welcome to devnet,
I haven't done something like that but intuitively, I would check the implementation of the keyboard that is the closest to the one I would like to support.
What have you tried already ?
Are you writing a plug-in ?
Are you building QtVirtualKeyboard yourself ? -
Hi SGaist,
Thank you for your response and suggestions.
Here’s what I’ve done so far:
1. What I’ve tried already:
• I created a new folder (en_JP) in the layouts directory as an example for a new language layout.
• Inside this folder, I added main.qml (basic QWERTY layout) and symbols.qml (symbol layout) to define the layout structure.
• After building the Qt Virtual Keyboard module, I placed the generated build artifacts in the Qt/5.12/gcc/lib/ directory to ensure the updated module is being used.
• I created a simple application with a TextField to test the virtual keyboard. The keyboard displays correctly for existing languages, but the new layout does not appear as an option.
2. Am I writing a plug-in?:
• No, I am not writing a custom plug-in. I am trying to add a new language layout by creating the necessary .qml files in the layouts folder and then rebuilding the Qt Virtual Keyboard module.
3. Am I building Qt Virtual Keyboard myself?:
• Yes, I am building the Qt Virtual Keyboard module locally after making changes to the layouts folder. The build completes successfully, and the keyboard works as expected for existing languages.
4. Current Issue:
• After opening the app, the new layout (en_JP) does not appear in the language options. I suspect that additional steps are required to register a new language.
• Specifically, I think it might be necessary to add the new language to a configuration or registration file. However, I’m not sure which file or files need to be modified to properly register a completely new language layout.
5. What I’ve referred to:
• I referred to the documentation on Keyboard Layouts. However, while it describes adding custom layouts, it does not cover the process for registering entirely new languages.Questions:
• Is there a specific configuration or file (such as languages.qml) where new languages must be explicitly registered?
• Can the Qt Virtual Keyboard dynamically detect and load new layouts, or is manual registration always required?
• Are there additional steps or settings needed for the new language to appear in the language menu?Any guidance on how to properly register and display a new language layout in the keyboard would be greatly appreciated.
Thank you again for your help.
-
Hi,
have you looked into this already?Build command options:
The first row in the table says something about languages.
-
Hi,
Thank you for sharing info.I have made some progress in adding a new layout (en_JP) to the Qt Virtual Keyboard (QVK), but I am still facing challenges in fully resolving the issue. Below is the current status:
Steps Taken
-
Created layout folder and files
• Added necessary files (e.g., main.qml) under the directory:
qtvirtualkeyboard/src/virtualkeyboard/content/layouts/en_JP/. -
Registered the layout in the .pro file
• Added the following configuration to virtualkeyboard.pro to include the custom layout in the build:
contains(CONFIG, lang-en(_JP)?) { LAYOUT_FILES += \ content/layouts/en_JP/dialpad.fallback \ content/layouts/en_JP/digits.fallback \ content/layouts/en_JP/main.qml \ content/layouts/en_JP/numbers.fallback \ content/layouts/en_JP/symbols.fallback }
- Build configuration
• Updated Qt/5.12.12/Src/qtvirtualkeyboard/src/config.pri to include all languages in the build:
CONFIG += lang_all
- Build and verification
• Built the module and confirmed that the new language appears in the list of available languages in QVK.
• Verified that the custom layout is displayed correctly when the new appeared language is selected.
Current Issue
While the new language (en_JP) is successfully added, the displayed language name still defaults to “English America”. I want it to show “English Japanese” in the following places:
• The language selection menu (accessed via the globe icon).
• Above the spacebar on the keyboard.Attempts So Far
• I suspect that setting the correct locale is necessary, but I could not find any concrete information or clues about how to proceed.Questions
1. What steps are required to display the language name as “English Japanese”?
2. Are there specific files or code that need to be modified to set the correct language name and locale?
3. If Qt Virtual Keyboard determines the display name automatically based on the language code (en_JP), how can this behavior be customized?Your guidance on resolving this issue would be greatly appreciated. Thank you!
-