Re: i8n
Here are English and Spanish .po files for testing (Spanish is machine translation, with a little help)
Interesting app, but not sure what it's for..
BTW the Project options are missing:
Icon (which crashes the About dialog)
Target Filename(=LazModel)
which prevents i8n translation (maybe then no need for symlink if a relative path is also specified, and /locale is copied over?*)
*This is why (for distribution) I bundle the po files as a resource then unpack them (if not already present) to a /locale folder in form initialization - that way, they are always available even if the executable is moved.
No need for DefaultTranslator in unit uMainModule or anywhere else
Option 1: In uMainForm replace Uses: DefaultTranslator -> LCLTranslator
In Form.Create:
procedure TMainForm.FormCreate(Sender: TObject);
begin
Height := Max( Round(Screen.Height * 0.75), 480 );
Width := Max( Round(Screen.Width * 0.75) , 640 );
{$IFDEF DEBUG}
ClassTreeEditForm := TClassTreeEditForm.Create(Self);
{$ENDIF DEBUG}
SetDefaultLang('fi','locale',true); // <<< testing - can now be 'en' and 'es' etc.
MainModule := TMainModule.Create(Nil);
end;
..or better still Option 2: you can put it in the LPR file
Uses ...long list..., LCLTranslate;
Application.Initialize;
Application.Title := 'Laz-Model';
SetDefaultLang('fi','locale',true); // <<< testing - can now be 'en' and 'es' etc
Application.CreateForm(TMainForm, MainForm);
Application.Run;
As I remember DefaultTranslator just calls LCLTranslator.SetDefaultLang('','',true) and LCLTranslator looks for 'locale', 'language' etc as folders that contain .po files, and uses the system settings to set the language prefix.
Anyway, i8n seems to work okay in Windows 10, but the code needs more strings to be made into resourcestrings throughout the project
i.e. (in uMainModule)
ShowMessage(
'Syntax: '#9 + ChangeFileExt(ExtractFileName(Application.ExeName),'') + ' [options] [@list] [files...]'#13#10#13#10 +
'Valid options are:'#13#10#13#10+
' -d[path]'#9'Generate documentation to the path specified'#13#10 +
' -a[+/-]'#9'Show associations on generated diagrams on/off'#13#10 +
' -v[0-3]'#9'Visibilty filter for generated diagrams'#13#10 +
' -x[file]'#9'Export model to xmi file')
which needs to use Format('',[]) (or ShowMessageFmt) and the const LineEnding (as a parameter) rather than #13#10. The (format %s,%d etc)-type strings are better for resourcestrings/translation to work with. You can also use Highlight String->Right-click->Refactoring->Make resourcestring in the IDE editor pane to make it easy.
something like:
Var sInShowHelp:String
begin
....
sInShowHelp:='Syntax: %s%s [options] [@list] [files...]%s%s' +
'Valid options are:%s%s' +
'%s-d[path]%sGenerate documentation to the path specified%s' +
'%s-a[+/-]%sShow associations on generated diagrams on/off%s' +
'%s-v[0-3]%sVisibilty filter for generated diagrams%s' +
'%s-x[file]%sExport model to xmi file';
ShowMessageFmt(sInShowHelp,
['#9',ChangeFileExt(ExtractFileName(Application.ExeName),''),LineEnding,LineEnding,
LineEnding,LineEnding,
'#9','#9',LineEnding,
'#9','#9',LineEnding,
'#9','#9',LineEnding,
'#9','#9'
]);
...
end;
..where the string variable sInShowHelp text can become a valid resourcestring that is more easily translateable in poedit
I really like the i8n facilities in Lazarus
(all applies to trunk BTW)