{"id":27180137,"url":"https://github.com/jmarrec/qtinternationalization","last_synced_at":"2025-04-09T14:25:42.667Z","repository":{"id":52466493,"uuid":"362245710","full_name":"jmarrec/QtInternationalization","owner":"jmarrec","description":"A simple project to show how to use Qt Linguist to translate and app (via CMake)","archived":false,"fork":false,"pushed_at":"2021-05-17T09:17:52.000Z","size":324,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-11T16:07:33.793Z","etag":null,"topics":["cmake","cpp","example","internationalization","qt","qt-linguist"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmarrec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-27T20:43:31.000Z","updated_at":"2024-06-11T16:07:33.793Z","dependencies_parsed_at":"2022-09-01T15:24:26.552Z","dependency_job_id":null,"html_url":"https://github.com/jmarrec/QtInternationalization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmarrec%2FQtInternationalization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmarrec%2FQtInternationalization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmarrec%2FQtInternationalization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmarrec%2FQtInternationalization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmarrec","download_url":"https://codeload.github.com/jmarrec/QtInternationalization/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054529,"owners_count":21040020,"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":["cmake","cpp","example","internationalization","qt","qt-linguist"],"created_at":"2025-04-09T14:25:42.117Z","updated_at":"2025-04-09T14:25:42.662Z","avatar_url":"https://github.com/jmarrec.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Simple project to demonstrate how Internationalization works in Qt (with CMake)\n\nI created a simple QLabel with a `tr` (instead of a plain `QString`)\n\n![Before](doc/before.png)\n\nI then used Qt Linguist to translate the ts file: very easy! The hardest part was how to launch qt linguist. I expected Qt Creator to propose it, but couldn't find that.\nI located the tool at `~/Qt/6.0.3/gcc_64/bin/linguist` (using `find` command).\n\n![Qt Linguist](doc/qt_linguist.png)\n\nThen modified [main.cpp](main.cpp) to install a translator, and voilà !\n\n![After](doc/after.png)\n\n## Adding another translation\n\nI'm going to show how to do add translation for Spanish for example:\n\n1. Register a new translation file in `CMakeLists.txt`\n\n```diff\nset(TS_FILES\n  translations/QtInternationalization_fr_FR.ts\n+ translations/QtInternationalization_es_ES.ts\n)\n```\n\nNow build again. That file will be created.\n\n**Note:** this is **better** than actually copying the French one because that way Qt `linguist` will show you in the UI what you haven't translated yet.\n\n2. Open qt `linguist`. You can load **both** translation files at the same time to get more context. Add your translation, save with \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eEnter\u003c/kbd\u003e\n\n![Qt Linguist, adding spanish translation](doc/Add_spanish_translation.png)\n\nYou can see [PR#2](https://github.com/jmarrec/QtInternationalization/pull/2) for the actual code changes I did.\n\n## Testing it out\n\nAfter building, you can launch the executable by passing `LANG=` env variable\n\n```\n# Default to your current locale, english in my case\n./QtInternationalization\nLANG=fr_CA.UTF-8 ./QtInternationalization\nLANG=fr_FR.UTF-8 ./QtInternationalization\nLANG=es_ES.UTF-8 ./QtInternationalization\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmarrec%2Fqtinternationalization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmarrec%2Fqtinternationalization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmarrec%2Fqtinternationalization/lists"}