GSAK (Geocaching Swiss Army Knife)
Contents - Index

MakeTranslation (command)

MakeTranslation FileIn=txtFile FileOut=silFile

Use this command to generate a Translation master file from a simple text file.

Macros do not have to be multilingual, but for those macro authors that wish to publish their macros in multiple languages, GSAK can help you.

Basically the process goes something like this:

1. Create your macro and forms in English
2. Create a plain text file (one line per entry) of all the words/phrases that need translation
3. Use the command "MakeTranslation" to generate your macro translation master ".SIL" file that will be used for translations.
4. Publish this file on the GSAK forum so that translators can do the translation for you
5. When translations are sent to you, "merge" them into your generated master file using the Sil Editor tool
6. Change your macro to convert all literal text using the Translate() function
7. Include the translation file with your macro

To better understand this process we will follow a sample macro. It won't really do anything but it should explain what is required.

First we design our form and then write the macro code to display the form etc:
 

WHILE TRUE
  $FormExit = form($Form,"")
  BeginCase
      Case $FormExit = "SystemExit"
      CANCEL Msg="Macro Canceled"

      Case $FormExit = "btnOK"
      #<Insert code to do something or GOSUB here>
      BREAK

      Case $FormExit = "btnCancel"
      CANCEL Msg="Macro Canceled"
  EndCase
ENDWHILE  


<Data> VarName=$form
#********************************************************************
# Form generated by GSAK form designer on Mon 23-Apr-2012 16:39:41
#********************************************************************

Name = Form1
Type = Form
Height = 300
Width = 500

Name = Groupbox1
Type = Groupbox
Caption = Database update options
Height = 105
Left = 44
Top = 39
Width = 404
Taborder = 2

Name = btnOK
Type = Button
Height = 25
Left = 109
Top = 215
Width = 75
Taborder = 3
Caption = OK

Name = btnCancel
Type = Button
Height = 25
Left = 241
Top = 215
Width = 75
Taborder = 4
Caption = Cancel

Name = lblTest
Type = Label
Height = 17
Left = 139
Top = 11
Width = 114
Caption = Form to test translation

Name = rbtNew
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 15
Top = 43
Width = 98
Taborder = 0
Caption = Newer only

Name = rbtExisting
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 145
Top = 46
Width = 98
Taborder = 1
Caption = Existing

Name = rbtIgnore
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 276
Top = 43
Width = 98
Taborder = 2
Caption = Ignore

Name = chkSummary
Type = Checkbox
Height = 20
Left = 133
Top = 166
Width = 165
Taborder = 5
Caption = Show summary at end

<enddata>

 


Now we need to place all the "English" words/phrases in a plain text file that we want converted. You can use your favorite text editor, or if you don't have one, just use NotePad.
 

Form to test translation
Database update options
Newer only
Existing
Ignore
Show summary at end
OK
Cancel
Macro Canceled


Now we need to write and run a one line macro to Generate the required formatted ".SIL" file from this plain text file we just created. Assuming we saved the file as "c:\temp\TransTest.txt" our one line macro would be something like:
 

MakeTranslation Filein="c:\temp\transtest.txt" Fileout="c:\temp\TransTest.sil"

  
This should create our master ".SIL" file that can be given to translators. This same file used to "merge" in the translations and will be the master file you distribute with your macro. Before any translations are done, the bare bones file will look like:
 

[Language names - for internal use only!]
Language_1=English
Language_2=German
Language_3=French
Language_4=Dutch
Language_5=Danish
Language_6=Czech
Language_7=Swedish

[OPTIONS]
CommentsFile=
Delimiter=~!@#
IsUTF8File=0

[Strings]
TfmMacroTranslations.1=Form to test translation~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.2=Database update options~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.3=Newer only~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.4=Existing~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.5=Ignore~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.6=Show summary at end~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.7=OK~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.8=Cancel~!@#~!@#~!@#~!@#~!@#~!@#~!@#
TfmMacroTranslations.9=Macro Canceled~!@#~!@#~!@#~!@#~!@#~!@#~!@#

 
If we open this file in the SIL editor it will look something like:



Now we need to update our macro code to translate all our used strings. The syntax of this function is:

Translate(sData,[sTranlationFile]) : string

sData - This is the English word/phrase that needs to be translated
sTranslationFile - This is an optional parameter and should only be used if you want to use a language file that has a different name than the default one that this function looks for (same name as the macro but with a ".sil" extension)

Note: Macro commands do not support the use of functions. So we see that in our converted code we can't do something like:
 

Cancel Msg=Translate("Macro Canceled")

  
Rather we must allocate the translation to a variable and then use that:
 

$msg = Translate("Macro Canceled")
CANCEL Msg=$msg


Now here is the full converted code for the macro:
 

$form = EditForm($form,"Groupbox1","Caption",Translate("Database update options"))
$form = EditForm($form,"btnOk","Caption",Translate("OK"))
$form = EditForm($form,"btnCancel","Caption",Translate("Cancel"))
$form = EditForm($form,"lblTest","Caption",Translate("Form to test translation"))
$form = EditForm($form,"rbtNew","Caption",Translate("Newer only"))
$form = EditForm($form,"rbtExisting","Caption",Translate("Existing"))
$form = EditForm($form,"rbtIgnore","Caption",Translate("Ignore"))
$form = EditForm($form,"chkSummary","Caption",Translate("Show summary at end"))


WHILE TRUE
  $FormExit = form($Form,"")
  BeginCase
      Case $FormExit = "SystemExit"
      $msg = Translate("Macro Canceled")
      CANCEL Msg=$msg

      Case $FormExit = "btnOK"
      #<Insert code to do something or GOSUB here>
      BREAK

      Case $FormExit = "btnCancel"
      $msg = Translate("Macro Canceled")
      CANCEL Msg=$msg
  EndCase
ENDWHILE  


<Data> VarName=$form
#********************************************************************
# Form generated by GSAK form designer on Mon 23-Apr-2012 16:39:41
#********************************************************************

Name = Form1
Type = Form
Height = 300
Width = 500

Name = Groupbox1
Type = Groupbox
Caption = Database update options
Height = 105
Left = 44
Top = 39
Width = 404
Taborder = 2

Name = btnOK
Type = Button
Height = 25
Left = 109
Top = 215
Width = 75
Taborder = 3
Caption = OK

Name = btnCancel
Type = Button
Height = 25
Left = 241
Top = 215
Width = 75
Taborder = 4
Caption = Cancel

Name = lblTest
Type = Label
Height = 17
Left = 139
Top = 11
Width = 114
Caption = Form to test translation

Name = rbtNew
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 15
Top = 43
Width = 98
Taborder = 0
Caption = Newer only

Name = rbtExisting
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 145
Top = 46
Width = 98
Taborder = 1
Caption = Existing

Name = rbtIgnore
Type = Radiobutton
Container = Groupbox1
Height = 20
Left = 276
Top = 43
Width = 98
Taborder = 2
Caption = Ignore

Name = chkSummary
Type = Checkbox
Height = 20
Left = 133
Top = 166
Width = 165
Taborder = 5
Caption = Show summary at end

<enddata>


Alpha List         Category List 



Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact