{"id":18023012,"url":"https://github.com/kanryu/qlanguageselector","last_synced_at":"2026-03-12T12:39:28.231Z","repository":{"id":140593617,"uuid":"98552632","full_name":"kanryu/qlanguageselector","owner":"kanryu","description":"A portable component that makes it possible to add and switch language resources of your application by users.","archived":false,"fork":false,"pushed_at":"2025-05-15T07:10:38.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-15T08:23:54.097Z","etag":null,"topics":["i18n","language-resources","multi-language","qbs","qt","qt5","translation"],"latest_commit_sha":null,"homepage":"","language":"QML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanryu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-27T15:29:36.000Z","updated_at":"2025-05-15T07:10:41.000Z","dependencies_parsed_at":"2023-05-03T19:47:00.848Z","dependency_job_id":null,"html_url":"https://github.com/kanryu/qlanguageselector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kanryu/qlanguageselector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fqlanguageselector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fqlanguageselector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fqlanguageselector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fqlanguageselector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanryu","download_url":"https://codeload.github.com/kanryu/qlanguageselector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fqlanguageselector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260148390,"owners_count":22965912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["i18n","language-resources","multi-language","qbs","qt","qt5","translation"],"created_at":"2024-10-30T07:06:41.099Z","updated_at":"2026-03-12T12:39:28.196Z","avatar_url":"https://github.com/kanryu.png","language":"QML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QLanguageSelector\nIt is a portable component that makes it possible to add and switch language resources of your application by users.\n\n![qlanguagemenu](https://user-images.githubusercontent.com/759165/49052552-b3479e00-f22f-11e8-87e3-e1568d29413d.png)\n\n## Summary\n\nQLanguageSelector provides a mechanism for applications to make language changes by users.\n\nEach language is automatically generated and registered as a child QAction menu of QMenu specified.\n\nEach language is described in the ini file (usually \"translations/languages.ini\").\n\nAllow users of your application to add new languages without changing the source code.\n\nWhen your application user selects the Language Menu,\n the QLanguageSelector automatically sets the new QTranslator\n to qApp and replaces the language resources of your application.\n\nEventually the languageChanged signal is emitted and you can handle additional change events.\n\n\nThis is a part of [QuickViewer](https://github.com/kanryu/quickviewer).\n\n## language.ini\n\nA list of translation files of your application is defined in language.ini. It has the following format.\n\n```\n[QLanguageSelector]\nForceUseText=false      \u003c-- If you always use text-based translation, set it to true\nReverseFile=Reverse.txt \u003c-- The file name of the reverse translation file is described here\n[Spanish]               \u003c-- Language Group\nCode=es                 \u003c-- Language Code(e.g. 'en' or 'en_US')\nCaption=Spanish         \u003c-- Language name which is used on main menu\nQm=quickviewer_es.qm    \u003c-- Qt based translation file name\nTextFile=Spanish.txt    \u003c-- Text based translation\n[YourLanguage]\nCode=\nCaption=YourLanguage\nQm=\nTextFile=YourLanguage.txt\nOpenTextEditor=true     \u003c-- Set to true if you want to trigger an event to edit a text translation\n...\n```\n\nImplementation example to see: [languages.ini of QuickViewer](https://github.com/kanryu/quickviewer/blob/master/QuickViewer/translations/languages.ini)\n\nWith the exception of the first QLanguageSelector group, the menu is displayed in this file in the order of the groups you described.\n\nThe translated file may be either a normal qm format or a text format provided by this library.\n\nSince QLanguageSelector reads language.ini at its initialization and generates QActions into the parent QMenu to switch translation languages, you do not need to rebuild your program when adding and editing translation languages.\n\n## Text based translations\n\nQLanguageSelector supports text based translation. It is an ini file of the following format. (For convenience of the user, it may be better not to have the extension **ini**)\n\n```\n; Language file was generated at Sun, 25 Nov 2018 21:09:55 +0900\n; === COMMENTS ===\n; This is a language file for QuickViewer. Lines beginning with ; are comments.\n; Each language should have one language file in UTF-8 character set.\n; When you change the text of this file, the notation of the application will be changed.\n; If you make a new translation or modify an existing one,\n; please post to Issue(https://github.com/kanryu/quickviewer/issues) or send an email to \u003ck.kanryu@gmail.com\u003e.\n; \n; Note 1: Use \\n (backslash+n) instead of new line for each text, if you need.\n; Note 2: 'hint' is a hint comment for each 'text'.\n; \n\n[MainWindow]\ntext_109001=\u0026Archivo\ntext_109002=\u0026Ver\ntext_109003=\u0026Ayuda\n;hint109004: End application\ntext_109004=\u0026Salir\n;hint109005: Automatically resize the image according to the size of the window\ntext_109005=\u0026Agrandamiento o Reducción de imagen automático\ntext_109006=\u0026Pantalla completa\ntext_109007=QuickViewer\n;hint109008: A menu for displaying a dialog for selecting an image to be displayed\ntext_109008=\u0026Abrir Carpeta de Imagenes\ntext_109009=\u0026Historia\n...\n```\n\nImplementation example to see: [Japanese.txt](https://gist.github.com/kanryu/e935cd60afbd0f7f770755dd1113ff99)\n\nThe *text_XXXXXX* part is automatically generated, so you can not convert perfectly with this single translation file. Always requires a **reverse translation** file.\n\nThe part of *hintXXXXXX* can be written in the second argument of **tr()** function. However, Qt's translation file is clever, so if the character string of the first argument is the same but the annotation of the second argument is different, it becomes a different translation word, but since this library can **NOT** be distinguished, such description should not be done.\n\n## Generate text based translation\n\nThese translation files are automatically converted from the ts files of your application.\n\nThe conversion process can be described by qbs. It would be easy if you made the project with qbs.\n\nImplementation example to see: [maketransconf.qbs](https://github.com/kanryu/quickviewer/blob/master/QuickViewer/translations/maketransconf.qbs)\n\n\nIf your project is written in qmake, you need a little twist, but automation is possible. Please add the following settings to your installation process.\n\n\n    install_translations.path = $${MY_DEFAULT_INSTALL}/translations\n    install_translations.commands = $$shell_path($$[QT_INSTALL_BINS]/../../../Tools/QtCreator/bin/qbs) -f $${PWD}/translations/maketransconf.qbs qbs.installRoot:$${MY_DEFAULT_INSTALL}\n    install_translations.files = \\\n        $${PWD}/translations/languages.ini \\\n        $${PWD}/translations/quickviewer_ja.qm \\\n        $${PWD}/translations/quickviewer_es.qm \\\n        $${PWD}/translations/quickviewer_zh.qm \\\n        $${PWD}/translations/quickviewer_el.qm \\\n        $${PWD}/translations/qt_el.qm \\\n        $$[QT_INSTALL_TRANSLATIONS]/qt_zh_CN.qm \\\n\nThe entire project file to see: [QuickViewer.pro](https://github.com/kanryu/quickviewer/blob/master/QuickViewer/QuickViewer.pro)\n\n## License\nBSD-2\nCopyright (c) 2017, KATO Kanryu\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanryu%2Fqlanguageselector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanryu%2Fqlanguageselector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanryu%2Fqlanguageselector/lists"}