{"id":2924,"date":"2015-10-19T14:42:52","date_gmt":"2015-10-19T06:42:52","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=2924"},"modified":"2017-09-11T12:37:19","modified_gmt":"2017-09-11T04:37:19","slug":"qlang-%e5%a6%82%e6%9e%9c%e5%9c%a8%e7%94%a8%e6%88%b7%e6%9b%b4%e6%94%b9%e8%af%ad%e8%a8%80%e6%97%b6%e5%8f%98%e6%9b%b4%e5%8a%a8%e6%80%81%e6%b7%bb%e5%8a%a0%e5%86%85%e5%ae%b9%e7%9a%84%e5%80%bc","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=2924","title":{"rendered":"[QLang] \u5982\u4f55\u5728\u7528\u6237\u66f4\u6539\u8bed\u8a00\u65f6\u53d8\u66f4\u52a8\u6001\u6dfb\u52a0\u5185\u5bb9\u7684\u503c"},"content":{"rendered":"<p>\u6211\u4eec\u77e5\u9053\uff0cQLang \u53ef\u4ee5\u627f\u62c5\u7edd\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u7684\u81ea\u52a8\u7ffb\u8bd1\u4efb\u52a1\uff0c\u4f46\u662f\uff0c\u5982\u679c\u60a8\u7684\u6709\u4e9b\u5185\u5bb9\u662f\u52a8\u6001\u6dfb\u52a0\u7684\uff0c\u90a3\u4e48\u5f88\u663e\u7136\uff0cQLang \u5c31\u9700\u8981\u60a8\u7684\u4eba\u5de5\u5e72\u4e88\u4ee5\u5b9e\u73b0\u51c6\u786e\u7684\u7ffb\u8bd1\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u6211\u4eec\u5728\u7a97\u4f53\u4e0a\u653e\u7f6e\u4e00\u4e2a TLabel\uff0c\u5728 Form \u7684 OnCreate \u91cc\u4e3a\u5176\u52a8\u6001\u8d4b\u503c\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TForm1.FormCreate(Sender:TObject);\r\nbegin\r\n...\r\nLabel1.Caption:=_('Hello,world');\r\n...\r\nend;<\/pre>\n<p>\u8fd9\u6837\u5b50\uff0c\u7a0b\u5e8f\u5728\u542f\u52a8\u65f6\uff0c\u8bbe\u7f6e\u4e86 Label1 \u7684\u6807\u9898\u4e3a Hello,world \u7684\u5f53\u524d\u8bed\u8a00\u7ffb\u8bd1\uff0c\u5982\u679c\u7528\u6237\u53d8\u66f4\u4e86\u8bed\u8a00\uff0c\u6211\u4eec\u8fd9\u91cc\u6709\u4e24\u4e2a\u9009\u62e9\uff1a<\/p>\n<ol>\n<li>\u8ba9\u7528\u6237\u91cd\u542f\u7a0b\u5e8f\uff0c\u4ee5\u4fbf\u4f7f\u7528\u65b0\u7684\u8bed\u8a00\u663e\u793a\u5185\u5bb9\uff1b<\/li>\n<li>\u4f7f\u7528 LangManager.AddListener \u6dfb\u52a0\u4e00\u4e2a\u8bed\u8a00\u53d8\u66f4\u4e8b\u4ef6\u7684\u54cd\u5e94\uff0c\u5728\u5176\u4e2d\u52a0\u5165\u54cd\u5e94\u4ee3\u7801\uff1a\n<pre class=\"lang:delphi decode:true \">...\r\nLangManager.AddListener(DoLanguageChanged);\r\n...\r\n\r\nprocedure TForm1.DoLanguageChanged(ASender:TObject);\r\nbegin\r\nLabel1.Caption:=_('Hello,world');\r\nend;\r\n...<\/pre>\n<p>\u6ce8\u610f\u4e00\u70b9\uff0c\u5728\u5f53\u524d\u7a97\u4f53\u91ca\u653e\u524d\uff0c\u5e94\u8c03\u7528 LangManager.RemoveListener\u6765\u79fb\u9664\u5bf9\u8bed\u8a00\u53d8\u66f4\u4e8b\u4ef6\u7684\u54cd\u5e94\u3002<\/li>\n<\/ol>\n<p>\u7ecf\u8fc7\u4e0a\u8ff0\u7684\u5904\u7406\uff0c\u4f60\u7684\u7a0b\u5e8f\u5df2\u7ecf\u80fd\u5b8c\u7f8e\u7684\u5e94\u5bf9\u7528\u6237\u8bed\u8a00\u5207\u6362\u64cd\u4f5c\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u77e5\u9053\uff0cQLang \u53ef\u4ee5\u627f\u62c5\u7edd\u5927\u591a\u6570\u60c5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,9,464],"tags":[475,296,324,460],"class_list":["post-2924","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-qdac","category-qlang","tag-475","tag-296","tag-324","tag-460"],"views":4521,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2924"}],"version-history":[{"count":2,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2924\/revisions"}],"predecessor-version":[{"id":4670,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2924\/revisions\/4670"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}