lazarus開發多國語言程序的步驟
1、project-->Options-->i18n-->Enable i18n
選擇多國語言文件保存目錄,默認和project同一目錄
![]()
1、project-->Options-->i18n-->Enable i18n
選擇多國語言文件保存目錄,默認和project同一目錄

2、在uses添加DefaultTranslator單元
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,DefaultTranslator;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;

4、使用POedit軟件(poedit下載地址:https://poedit.net/),打開project1.pot

5、點創建新的編譯

6、選擇要編譯的語言(示例選擇:中文)
7、將源文本ID逐一翻譯

8、保存翻譯好的po文件。
注意:文件名格式為:
執行文件名.語言代碼
如:project1.zh_CN.po

最后是運行后的程序:



浙公網安備 33010602011771號