merge
authorkoda
Wed, 06 Apr 2011 00:30:02 +0200
changeset 5111 d8856d98ce7d
parent 5109 6d2e8a24277e (current diff)
parent 5110 d48230ef9447 (diff)
child 5112 4e2ebd8ac298
merge
hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas	Wed Apr 06 00:29:49 2011 +0200
+++ b/hedgewars/hwengine.pas	Wed Apr 06 00:30:02 2011 +0200
@@ -260,13 +260,16 @@
     InitKbdKeyTable();
 
     LoadLocale(Pathz[ptLocale] + '/en.txt');  // Do an initial load with english
+    if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5)
+    else cLocale := Copy(cLocaleFName,1,2);
     if cLocaleFName <> 'en.txt' then
         begin
         // Try two letter locale first before trying specific locale overrides
-        if (Length(cLocaleFName) > 6) and (Copy(cLocaleFName,1,2)+'.txt' <> 'en.txt') then
-            LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocaleFName,1,2)+'.txt');
+        if (Length(cLocale) > 2) and (Copy(cLocale,1,2) <> 'en') then
+            LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocale,1,2)+'.txt');
         LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName);
-        end;
+        end
+    else cLocale := 'en';
 
     WriteLnToConsole(msgGettingConfig);
 
--- a/hedgewars/uSound.pas	Wed Apr 06 00:29:49 2011 +0200
+++ b/hedgewars/uSound.pas	Wed Apr 06 00:30:02 2011 +0200
@@ -20,7 +20,7 @@
 
 unit uSound;
 interface
-uses SDLh, uConsts, uTypes;
+uses SDLh, uConsts, uTypes, sysutils;
 
 var MusicFN: shortstring;
 
@@ -61,13 +61,29 @@
 
 function  AskForVoicepack(name: shortstring): Pointer;
 var i: Longword;
+    locName, path: shortstring;
 begin
 i:= 0;
+    // First, attempt to locate a localised version of the voice
+    if cLocale <> 'en' then
+        begin
+        locName:= name+'_'+cLocale;
+        path:= Pathz[ptVoices] + '/' + locName;
+        if DirectoryExists(path) then name:= locName
+        else if Length(cLocale) > 2 then
+            begin
+            locName:= name+'_'+Copy(cLocale,1,2);
+            path:= Pathz[ptVoices] + '/' + locName;
+            if DirectoryExists(path) then name:= locName
+            end
+        end;
+
+    // If that fails, use the unmodified one
     while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
-    begin
+        begin
         inc(i);
         TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
-    end;
+        end;
 
     voicepacks[i].name:= name;
     AskForVoicepack:= @voicepacks[i]
--- a/hedgewars/uVariables.pas	Wed Apr 06 00:29:49 2011 +0200
+++ b/hedgewars/uVariables.pas	Wed Apr 06 00:30:02 2011 +0200
@@ -33,6 +33,7 @@
     isSoundEnabled  : boolean     = true;
     isMusicEnabled  : boolean     = false;
     cLocaleFName    : shortstring = 'en.txt';
+    cLocale         : shortstring = 'en';
     cInitVolume     : LongInt     = 100;
     cTimerInterval  : LongInt     = 8;
     PathPrefix      : shortstring = './';