Archicad C++ API
About Archicad add-on development using the C++ API.

Localization strings

Anonymous
Not applicable
Hi,

I can`t get over following problem:

I have a GRC file with expressions to localize, but I cant make resource compiler to handle them. I tried to modify the compileGRCs.pl file, but its always the same: as soon as it finds a special character, it reports an error. I studied the documentation for several hours and there is described always only a way to sort the files themselves or make references to the strings, but never how to change the encoding.

I found a function called CHGetUserCharCode / CHSetDefaultCharCode but either I`m using it wrong or its not working..

So - where should the localized sentences be? I believe it`s the project_name.grc file under 'STR#' commands? I can now track them via ACAPI_Resource_GetLocStr (without the special characters of course)..

I`m working on macbook with Xcode 3.2.4 and DevKit 14.

Thanks,

Santi
8 REPLIES 8
Ralph Wessel
Mentor
santi wrote:
I have a GRC file with expressions to localize, but I cant make resource compiler to handle them.
Is the resource compiler crashing or failing to produce the required output? If so, can you post the perl script you are using to drive the compiler?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
alright, so the compiler stops on
#include "Dim_Round.grc.ro"
in the Dim_Round.r file

and generates an output as:
Converting resource files:
	Dim_RoundFix.grc
	Dim_Round.grc
Cannot get length of string, the string was ok until:
                                                                                
  (now the whole grc file until the special character is present, ends before it - it does not display the special character)

The unmappable charater is:
\u0161
Write_Error: GeneralError: Memory allocation error
done.                                                                  
 
the perl script is as I found it in examples:
#! /usr/bin/perl -w

use FindBin ;
use File::Spec::Functions;
use File::Copy;
use Cwd;

#-----------------------------------------------------------------------
# Executes one GRC conversion command
#-----------------------------------------------------------------------
sub DoGRC ($$$$$)
{
	my ($tool, $sourceDir, $inputFile, $destinationDir, $outputFile) = @_ ;

	system ("mkdir -p \"" . $destinationDir . "\"") ;
#	print $tool . " -m r -u 1 -q utf8 0 -T M -i \"" . catfile ($sourceDir, $inputFile) . "\" -j .roo -p \"" . catfile ($sourceDir, "Images") . "\" -o \"" . catfile ($destinationDir, $outputFile) . "\"\n" ;
	print "\t$inputFile\n";
	system ($tool . " -m r -u 1 -q utf8 0 -T M -i \"" . catfile ($sourceDir, $inputFile) . "\" -j .roo -p \"" . catfile ($sourceDir, "Images") . "\" -o \"" . catfile ($destinationDir, $outputFile) . "\"");
}


#-----------------------------------------------------------------------
# Convert GRC
#-----------------------------------------------------------------------
print "Converting resource files:\n";

my $devKitPath = catfile ($FindBin::Bin, updir (), updir (), updir ());
my $makeResConvTool = "\"" . catfile (Cwd::realpath ($devKitPath), "Support", "Tools", "OSX", "ResConv") . "\"";

my $examplePath = Cwd::realpath (catfile ($FindBin::Bin, updir ()));
my $resTarget = catfile ($ENV{TARGET_BUILD_DIR}, $ENV{UNLOCALIZED_RESOURCES_FOLDER_PATH});
my $roFolder = catfile ($examplePath, "RO");

DoGRC ( $makeResConvTool, catfile ($examplePath, "RFIX"), "Dim_RoundFix.grc", $roFolder, "Dim_RoundFix.grc.ro" ) ;
DoGRC ( $makeResConvTool, catfile ($examplePath, "RINT"), "Dim_Round.grc", $roFolder, "Dim_Round.grc.ro" ) ;

opendir (DIR, $roFolder);
@files = readdir (DIR);
closedir (DIR);

foreach $file (@files) {
    copy (catfile ($roFolder, $file), $resTarget) if ($file =~ /.*\.tif$/);
}

print "done.\n";
I thought that problem would be the coding, but documentation gives me no other choise than present
-q utf8 0
Thanks a lot
Ralph Wessel
Mentor
santi wrote:
I thought that problem would be the coding, but documentation gives me no other choise than present
I tested this and hit the same problem. It looks like a bug in the GRC compiler - I think we need some input from someone at GS here.
Ralph Wessel BArch
Software Engineer Speckle Systems
Akos Somorjai
Graphisoft
Graphisoft
Ralph wrote:
santi wrote:
I thought that problem would be the coding, but documentation gives me no other choise than present
I tested this and hit the same problem. It looks like a bug in the GRC compiler - I think we need some input from someone at GS here.
The '-q utf8 0' specifies that the source file's encoding is UTF8. Can you just input that character as a 'normal' character instead of specifying it as a unicode character? Also, the '0' means Mac Roman encoding (old script manager script code), if you use a different language you may have to specify another value here as well.

Best, Akos
Anonymous
Not applicable
Well, I tried
-q utf8 utf8
and that worked, compiler succeeded and text is readable But I cant get any other coding in there, so maybe this would be the head question and answer:
Where do I find the list of <script_code> encodings in a format for compiler? I mean in a GSCharCode format its a number from 0 to 100 or "CC_Name", but in the perl script its something else. I tried to search the documentation and found nothing..

thanks a lot
Anonymous
Not applicable
Hi,

we made a little progress in API development but we are stuck again on the encoding of GRC Compiler:

grc file on a macintosh platform via the perl script in CompileGRCs.pl:
system ($tool . " -m r -u 1 -q utf8 0 -T M -i \"" . catfile ($sourceDir, $inputFile) . "\" -j .roo -p \"" . catfile ($sourceDir, "Images") . "\" -o \"" . catfile ($destinationDir, $outputFile) . "\"");
Now I need to add my counry/region encoding - for Czech Republic it is Eastern Europe on windows 1250 - that works well. But on Mac if I tried:
-q utf8 1250
-q utf8 1252 
-q utf8 65001 
-q utf8 10029
and it just doesnt work.. am I doing something wrong? The file compiles but the characters are wrong. I am testing it on czech version of archicad - AC 15 CZE. Again, on Windows is a little bit different process but it works with
-q utf8 1250
Thanks,

Santi
Akos Somorjai
Graphisoft
Graphisoft
santi wrote:
Hi,

we made a little progress in API development but we are stuck again on the encoding of GRC Compiler:

grc file on a macintosh platform via the perl script in CompileGRCs.pl:
system ($tool . " -m r -u 1 -q utf8 0 -T M -i "" . catfile ($sourceDir, $inputFile) . "" -j .roo -p "" . catfile ($sourceDir, "Images") . "" -o "" . catfile ($destinationDir, $outputFile) . """);
Now I need to add my counry/region encoding - for Czech Republic it is Eastern Europe on windows 1250 - that works well. But on Mac if I tried:
-q utf8 1250
-q utf8 1252 
-q utf8 65001 
-q utf8 10029
and it just doesnt work.. am I doing something wrong? The file compiles but the characters are wrong. I am testing it on czech version of archicad - AC 15 CZE. Again, on Windows is a little bit different process but it works with
-q utf8 1250
Thanks,

Santi
Hello Santi,

This is a bit trickier than that.

On Mac you'll have to use the appropriate CFStringEncoding for your region; for Czech it's 29 == kCFStringEncodingMacCentralEurRoman. You can find all the possible values in /System/Library/Frameworks/CoreFoundation.framework/Headers/CFStringEncodingExt.h).
On Windows - as you have already discovered - you have to pass the code page.

So the correct parameters for Czech would be -q utf8 29.

As part of the general direction towards a full Unicode ArchiCAD, we plan to make changes to this system in one of the next major releases.

Best, Akos
Anonymous
Not applicable
that works well, thanks a lot we would have never find out this one 🙂

Santi