Poor man’s translation tool?

Poor man’s translation tool?

We need to do a multilingual version of a command line tool and I was thinking … yeah, I know … that is usually the first point of warning before I get into trouble. Anyways – this is what I came up with this evening.

I guess this is pretty much a brute force approach – but it appears to have some advantages – such as enforcing coverage of every language that you declare (it won’t compile if you missed a language in a translation constant), allowing you to declare the translations near where they are used, and not adding much bulk to the source code.

But – let me run this by you guys and ask – apart from the obvious reasons that there are actual translation tools out there – is there a reason that I really should not venture down this path?  What are the worst traits of this approach?  Note that I would use it  for only three languages (English, Norwegian and Swedish).

Come on – I want opinions – so don’t hold back, but feel free to suggest alternatives as well.

http://pastebin.com/g3DwKNAu

FMX and iMac 5K Retina?

FMX and iMac 5K Retina?

Can FMX deal well with this comparatively extreme resolution?

VCL has the same challenges with the new 3K and 4K displays under Windows 8.1 using system font scaling. 

Even in the IDE, we already run into design time issues, as the forms are mangled if designed at one resolution/font scaling, and then are opened on another PC at a different resolution/font scaling.

I wonder, are there any plans to look at solutions to this issue in the near future?

Inspired by Stefan Glienke’s post about the new intrinsic type related functions in XE7, I went spelunking in the…

Inspired by Stefan Glienke’s post about the new intrinsic type related functions in XE7, I went spelunking in the VCL and RTL differences between XE6 and XE7. More differences than I expected.

Some of them stand out.

TStream got a big overhaul. I wonder if it did anything to it’s performance, or if it was mostly about doing away with a lot of potentially troublesome endian related shl/shr operations?   Atleast the code looks a lot cleaner now.

DesignIntf has a new method

function CreateChild(ComponentClass: TComponentClass; Parent: TComponent): TComponent;

Windows.WinApi adds a number of Windows API functions related to locale, time, date and languages, as well as SID to String and String to SID, and what appears to be a relatively complete list of country codes CTRY_xxxx (Norway = 47, Germany=49, France=33, UK=44, US=1). Interestingly, these are not unique numbers. Go figure.

XE7’s new dynamic array syntax – take 2

XE7’s new dynamic array syntax – take 2

The syntax change also introduced a new ambiguity between argument types array of type and array of const.

Not sure that it is the appropriate error – as you should not be able to pass [] as an argument to a var parameter?

program XE7Tests2;

{$APPTYPE CONSOLE}

{$R *.res}

uses

  System.SysUtils, Variants;

type

  TVarArray = array of Variant;

  TTest = class

    function StoredProc(ConstParams: array of const): integer; overload;

    function StoredProc(var Params: TVarArray): integer; overload;

  end;

{ TTest }

function TTest.StoredProc(ConstParams: array of const): integer;

begin

end;

function TTest.StoredProc(var Params: TVarArray): integer;

begin

end;

var

  Test: TTest;

begin

  Test := TTest.Create;

  try

    try

      Test.StoredProc([]);  

// [dcc32 Error]: E2251 Ambiguous overloaded call to ‘StoredProc’

// Related method: function TTest.StoredProc(array of const): Integer;

// Related method: function TTest.StoredProc(var TVarArray): Integer;

    except

      on E: Exception do

        Writeln(E.ClassName, ‘: ‘, E.Message);

    end;

  finally

    Test.Free;

    Write(‘ – Enter: ‘);

    Readln;

  end;

end.

XE7’s new dynamic array syntax

XE7’s new dynamic array syntax

Good thing: Empty arrays can be used as default param value.

    procedure Test(const Params: TVarArray = []);

Bad thing: Variants not fully supported?

Try uncommenting CVarArr in the example below.

Doesn’t work and gives “Constant expression expected”.  

Yet the same constant list can be assigned to VVarArr

Go figure.

program XE7Tests;

{$APPTYPE CONSOLE}

{$R *.res}

uses

  System.SysUtils, Variants;

type

  TVarArray = array of Variant;

  TIntArray = array of Integer;

  TTest = class

    procedure Test(const Params: TVarArray = []);

  end;

{ TTest }

procedure TTest.Test(const Params: TVarArray);

var

  npar: Integer;

begin

  npar := High(Params) – Low(Params) + 1;

  Writeln(nPar);

end;

const

  CIntArr: TIntArray = [1,2,3];

//  CVarArr: TVarArray = [1,’2′, 3];  // “Constant expression expected”

var

  Test: TTest;

  VVarArr : TVarArray;

  VIntArr : TIntArray;

begin

  Test := TTest.Create;

  try

    try

      Test.Test;      // 0

      Test.Test(nil); // 0

      Test.Test([1,’2′, 3]); // 3

      VVarArr := [1,’2′, 3, 3.14];

      Test.Test(VVarArr); // 4

      Test.Test(VVarArr + [‘five’]); // 5

//      Test.Test(VVarArr + CVarArr); // Should have been 7

    except

      on E: Exception do

        Writeln(E.ClassName, ‘: ‘, E.Message);

    end;

  finally

    Test.Free;

    Write(‘ – Enter: ‘);

    Readln;

  end;

end.