./project --LANG cs_CS./project -l en./project --lang en_EN
r:=LazarusResources.Find('unit1.de','PO');
I created *.lrs file form *.po files but this line (from wiki) seems not working
type TTransalateFromLazarusResourceResult = (trSuccess, trResourceNotFound, trTranslationError); function TryTranslateFromLazarusResource: TTransalateFromLazarusResourceResult;var LRes: TLResource; PO: TPOFile; SS: TStringStream; B: Boolean;begin Result := trResourceNotFound; LRes := LazarusResources.Find('lclstrconsts.nl','PO'); if LRes <> nil then begin SS := nil; PO := nil; try SS := TStringStream.Create(LRes.Value); //don't use TPoFile.Create(SS,True): it will crash on TranslateUnitResourceStrings if you do PO := TPoFile.Create(SS, False); try B := TranslateUnitResourceStrings('lclstrconsts',PO); if B then Result := trSuccess else Result := trTranslationError; except Result := trTranslationError; DebugLn('Exception while translating LclStrConsts unit form internal resources.'); end; finally if Assigned(SS) then SS.Free; if Assigned(PO) then PO.Free; end; end;end;
PODirectory :='/home/v1/Lazarus_Qt/lazarus/lcl/languages/'; GetLanguageIDs(Lang, FallbackLang); Translations.TranslateUnitResourceStrings('LCLStrConsts', PODirectory + 'lclstrconsts.%s.po', Lang, FallbackLang);
LRes := LazarusResources.Find('project.cs','PO'); writeln(LRes.Name+' '+LRes.Value+' '+LRes.ValueType);
@BartThanks for code, it is compilable but it does not translate.
@Bart: did you perhaps forgot the nl_Translations unit? Or how are we supposed to get that?