Kryuski / kryvich-delphi-localizer

Kryvich's Delphi Localizer
GNU Lesser General Public License v3.0
25 stars 6 forks source link

Resourcestring problem after switching from Delphi2010 to DelphiXE2 #1

Open smth76 opened 5 years ago

smth76 commented 5 years ago

getting the following here after compiling the exe under XE2 (was a 2010er compilation before):

LNG file creating error: Can't find the special string KDL_Localizer_rsKdlMark in "nsa.drc". Check whether the uFreeLocalizer.pas unit is used by your application.

any help appreciated!

JanDoggen commented 4 years ago

Late to the party, but I just got the same in Delphi 10.4 Sydney on first use Reason: Those two FreeTranslator lines were not yet in my project source Are they in yours?

novikovmaxim commented 3 years ago

Подтверждаю, есть такое дело. Delphi 10.4.1. Требует uFreeLocalizer.pas, хотя этот файл только в версии 4.1 имеется. А вот если проект делался в 4.1, то при переходе в 5.0 всё работает правильно, строка KDL_Localizer_rsKdlMark там остаётся.

Удивительно, KDL.Localizer в Uses прописан, внутри KDL.Localizer ресурс rsKdlMark = 'KDLMark*'; имеется, но он ни в какую не хочет прописываться в .drc

Вообще никакие ресурсы из KDL.Localizer не отправляются в .drc, с чем это может быть связано?

Решено! При компиляции проекта, Делфи, видимо, не сканирует включенные в проект модули на предмет строковых ресурсов, если к таковым в коде нет обращения. Поэтому не торопитесь опробовать работу утилит, не прописав в .dpr вашего проекта после Application.Initialize; вместе со строкой присвоения булева типа FreeLocalizer.AutoTranslate := True;, ещё и строку присвоения строкового типа FreeLocalizer.LanguageFile := 'myapp.en.lng';, даже если файла myapp.en.lng ещё нет. После присвоения строковой переменной в этот модуль, Делфи успешно нашла и строку KDL_Localizer_rsKdlMark.

Пожелание разработчикам — нужно более информативное сообщение, учитываюшее описанный нюанс, ну и заменить в сообщении uFreeLocalizer.pas на KDL.Localizer. А вообще — отличные утилиты! :-)

novikovmaxim commented 3 years ago

Обёртка для этих утилит, графический интерфейс: There is a wrapper for these utilities, a graphical interface:

http://novikov.gq/products/kdlgui/kdlgui.html

JanDoggen commented 3 years ago

I had made a small test program with several objects, resourcestrings etc, and that all worked fine Under Delphi 10.3.3 Some time later I pulled the required files into the actual program that needed to be translated, but kdlscan did not pick up the resourcestrings; the [ResourceStrings] section in the lng file was empty.

First I found that my program did not generate a .drc file - see http://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_Resource_String_File_(*.drc), so I checked 'Output resource string .drc file' in Project > Options > Delphi Compiler > Linking. That did not help, the drc file was generated, but now no .lng was generated at all!

Running kldscan from the command line I got the error:

LNG file creating error: Can't find the special string KDL_Localizer_rsKdlMark in "oktool.drc". Check whether the uFreeLocalizer.pas unit is used by your application.

That is exactly what novikovmaxim is talking about in his comment above. (dump it into Google translate)

It is essential that you include both of these lines in your project file:

FreeLocalizer.AutoTranslate := True; FreeLocalizer.LanguageFile := 'languagefile.lng';