Dxgettextgnugettext无法正确提取带有UTF-8单元上的重音符号的字符串

问题描述

我正在使用dxgettext转换Delphi 10.4项目,但认情况下定义了IDE保存为UTF文件,因此dxgettext仅从.dfm文件中正确地提取字符串,而从.pas文件中正确地提取了重音符号(会将其读取为ANSI字符串)。我可以验证两个文件在UTF-8中的编码是否相同。

我得到了像Hola Món这样的字符串,而不是Hola Món

像dxgettext这样的硬编码将所有.pas文件都视为ANSI文件。如果没有人可以帮助我配置dxgettext使其正确读取那些文件,我想我将不得不编写一个小工具将所有源文件复制到一个单独的文件夹,将.pas文件转码为ANSI,然后从那里调用dxgettext。 / p>

PS:我已经准备了一个显示问题的Hello World项目。

下载示例:https://gofile.io/d/bKeZod

这是项目的唯一单位(必须另存为UTF-8):

unit Unit1;

interface

uses
  Winapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}

uses gnugettext;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := _('Hola Món');
end;

end.

这是生成的default.po:

# SOME DESCRIPTIVE TITLE.
# copyright (C) YEAR THE PACKAGE'S copYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FirsT AUTHOR <EMAIL@ADDRESS>,YEAR.
# 
#,fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-10-29 14:39\n"
"PO-Revision-Date: 2020-10-29 14:39\n"
"Last-Translator: Somebody <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-transfer-encoding: 8bit\n"
"X-Generator: dxgettext 1.2.2\n"

#. Form1..Caption
#: Unit1.dfm:4
msgid "Aplicació de proves"
msgstr ""

#: Unit1.pas:28
msgid "Hola Món"
msgstr ""

已正确检索.dfm上的Form1.caption,但.pas文件上的字符串被读取为ANSI字符串。

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)