I'm using dxgettext to translate a Delphi 10.4 project, but having defined the IDE to save to UTF files by default, dxgettext only extracts strings correctly from the .dfm files, from the .pas files it reads incorrectly the accents (it reads them as ANSI strings). I can verify that both files are equally coded in UTF-8.
I get strings like Hola Món
instead of Hola Món
.
Looks like dxgettext is hardcoded to consider all .pas files as ANSI files. If no one can help me configure dxgettext to make it read correctly those files, I guess I will have to write an small tool to copy all source files to a separate folder, transcode the .pas files to ANSI and call dxgettext from there.
PS: I have prepared a Hello World project that shows the problem.
Download sample : https://gofile.io/d/bKeZod
This is the project's only unit (it must be saved as 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.
And this is the resulting 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 <your.email@address.com>\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 ""
The Form1.caption on the .dfm is correctly retrieved, but the string on the .pas file is read as an ANSI string.
Thank you.