was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

27 Visitors Online


 
...Messages in der eingestellen Sprache zurückgeben?
Autor: Walter Verhoeven
[ Tip ausdrucken ]  

Tip Bewertung (3):  
     


{
  Call inLanguage like this to get the German text else return english
  if you use different coutntry codes you can do more
}

{############### FGetLanguageSettings ############################
 # Author: Walter Verhoeven
 # Date:   14.Sep.2000
 # Coming From: InLanguage
 #  Next Event: NONE
 #  Parameters: NONE
 #   Objective: See the users regional settings and return Country #number code
 #   Change:
 #     DD-MMM-YYYYY ¦Programmer
 #                1)
 #
 ########################################################}
 
function FGetLanguageSettings: Integer;
var
  
OutputBuffer: PChar;
  SelectedLCID: LCID;               //DWORD constand in Windows.pas
begin
  
OutputBuffer := StrAlloc(4);     //alocate memory for the PChar
  
try
    try
      
SelectedLCID := GetUserDefaultLCID;
      GetLocaleInfo(SelectedLCID, LOCALE_ICOUNTRY, OutputBuffer, 3);
      Result := StrToInt(OutputBuffer);
    except
      
Result := 49;   //german
      
Abort;
    end;
  finally
    
StrDispose(OutputBuffer);   //alway's free the memory alocated
  
end;
end;

{############## INLanguage #######################################
 # Author: Walter Verhoeven
 # Date:   .Jun.2000
 # Coming From:
 #  Next Event: FGetLanguageSettings
 #  Parameters: Eglish and german text
 #   Objective: provide a method to return
 #              english or german results based on the
 # users window prefered language setting.
 #   Change:
 #     DD-MMM-YYYYY ¦Programmer
 #                1)
 #
 ##############################################################}
 

function INLanguage(English, German: string): string;
begin
  case 
FGetLanguageSettings of
    
49: Result  := German;   // Return the german string
    
43: Result  := German;   // If the PC has a german preferance
    
41: Result  := German;
    352: Result := German;
    else
      
Result := English;      // if not german then english
  
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  
ShowMessage(Format(INLanguage('My %s English Word',
    'Riesiges %s Software-Angebot'), ['Hopla']));
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners