diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-26 13:11:59 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-26 13:11:59 +0000 |
commit | 89ba488aa027281cda5c32f9bda5b9d98913fc12 (patch) | |
tree | 147410a773489c570a1369f29c17c006c4035b41 /unicode/src | |
parent | 59c10225f97f79ee4e702211b38dcd5493f05944 (diff) | |
download | usdx-89ba488aa027281cda5c32f9bda5b9d98913fc12.tar.gz usdx-89ba488aa027281cda5c32f9bda5b9d98913fc12.tar.xz usdx-89ba488aa027281cda5c32f9bda5b9d98913fc12.zip |
Language option fix:
- Never assume an order of the files returned by FindFirst/Next(). This will not work on linux as the order is random.
- That is also the reason why the default theme on linux is random (usdx uses the first theme returned by FindFirst(). This is not fixed yet.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1924 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | unicode/src/base/UIni.pas | 44 | ||||
-rw-r--r-- | unicode/src/base/ULanguage.pas | 30 | ||||
-rw-r--r-- | unicode/src/base/UMain.pas | 6 |
3 files changed, 26 insertions, 54 deletions
diff --git a/unicode/src/base/UIni.pas b/unicode/src/base/UIni.pas index 92e3418c..a3bc1876 100644 --- a/unicode/src/base/UIni.pas +++ b/unicode/src/base/UIni.pas @@ -334,43 +334,22 @@ uses * Translate and set the values of options, which need translation. *) procedure TIni.TranslateOptionValues; -const - NumberOfLanguages = 14; var - ErrorStringStart: string; + I: integer; begin - ULanguage.Language.ChangeLanguage(ILanguage[Language]); - - ErrorStringStart := 'The number of language files (' - + IntToStr(Length(ILanguage)) + ') is '; + // Load Languagefile + if (Params.Language <> -1) then + ULanguage.Language.ChangeLanguage(ILanguage[Params.Language]) + else + ULanguage.Language.ChangeLanguage(ILanguage[Ini.Language]); - if Length(ILanguage) > NumberOfLanguages then + SetLength(ILanguageTranslated, Length(ILanguage)); + for I := 0 to High(ILanguage) do begin - Log.LogError(ErrorStringStart + 'larger than expected (' + IntToStr(NumberOfLanguages) + ').', - 'Ini.TranslateOptionValues'); - Halt; + ILanguageTranslated[I] := ULanguage.Language.Translate( + 'OPTION_VALUE_' + UpperCase(ILanguage[I]) + ); end; - - if Length(ILanguage) < NumberOfLanguages then - Log.LogWarn(ErrorStringStart + 'smaller than expected (' + IntToStr(NumberOfLanguages) + ').', - 'Ini.TranslateOptionValues'); - - SetLength(ILanguageTranslated, NumberOfLanguages); - - ILanguageTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_CATALAN'); - ILanguageTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_CROATIAN'); - ILanguageTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_DUTCH'); - ILanguageTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_ENGLISH'); - ILanguageTranslated[4] := ULanguage.Language.Translate('OPTION_VALUE_EUSKARA'); - ILanguageTranslated[5] := ULanguage.Language.Translate('OPTION_VALUE_FINNISH'); - ILanguageTranslated[6] := ULanguage.Language.Translate('OPTION_VALUE_FRENCH'); - ILanguageTranslated[7] := ULanguage.Language.Translate('OPTION_VALUE_GERMAN'); - ILanguageTranslated[8] := ULanguage.Language.Translate('OPTION_VALUE_GREEK'); - ILanguageTranslated[9] := ULanguage.Language.Translate('OPTION_VALUE_ITALIAN'); - ILanguageTranslated[10] := ULanguage.Language.Translate('OPTION_VALUE_JAPANESE'); - ILanguageTranslated[11] := ULanguage.Language.Translate('OPTION_VALUE_PORTUGUESE'); - ILanguageTranslated[12] := ULanguage.Language.Translate('OPTION_VALUE_SPANISH'); - ILanguageTranslated[13] := ULanguage.Language.Translate('OPTION_VALUE_SWEDISH'); IDifficultyTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_EASY'); IDifficultyTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_MEDIUM'); @@ -936,7 +915,6 @@ begin // Language Language := GetArrayIndex(ILanguage, IniFile.ReadString('Game', 'Language', 'English')); - //Language.ChangeLanguage(ILanguage[Language]); // Tabs Tabs := GetArrayIndex(ITabs, IniFile.ReadString('Game', 'Tabs', ITabs[0])); diff --git a/unicode/src/base/ULanguage.pas b/unicode/src/base/ULanguage.pas index 02615fed..5f8a2692 100644 --- a/unicode/src/base/ULanguage.pas +++ b/unicode/src/base/ULanguage.pas @@ -52,9 +52,9 @@ type private List: array of TLanguageList; - Entry: TLanguageEntryArray; //**< Entrys of Chosen Language - SEntry: TLanguageEntryArray; //**< Entrys of Standard Language - CEntry: TLanguageEntryArray; //**< Constant Entrys e.g. Version + Entry: TLanguageEntryArray; //**< Entrys of Chosen Language + EntryDefault: TLanguageEntryArray; //**< Entrys of Standard Language + EntryConst: TLanguageEntryArray; //**< Constant Entrys e.g. Version Implode_Glue1, Implode_Glue2: UTF8String; @@ -113,9 +113,9 @@ begin begin ChangeLanguage('English'); - SetLength(SEntry, Length(Entry)); + SetLength(EntryDefault, Length(Entry)); for J := 0 to high(Entry) do - SEntry[J] := Entry[J]; + EntryDefault[J] := Entry[J]; SetLength(Entry, 0); @@ -226,10 +226,10 @@ begin // Check if ID exists //Const Mod - EntryIndex := FindID(ID, CEntry); + EntryIndex := FindID(ID, EntryConst); if (EntryIndex >= 0) then begin - Result := CEntry[EntryIndex].Text; + Result := EntryConst[EntryIndex].Text; Exit; end; @@ -242,10 +242,10 @@ begin //Standard Language (If a Language File is Incomplete) //Then use Standard Language - EntryIndex := FindID(ID, SEntry); + EntryIndex := FindID(ID, EntryDefault); if (EntryIndex >= 0) then begin - Result := SEntry[EntryIndex].Text; + Result := EntryDefault[EntryIndex].Text; Exit; end; end; @@ -255,9 +255,9 @@ end; *} procedure TLanguage.AddConst(const ID: AnsiString; const Text: UTF8String); begin - SetLength (CEntry, Length(CEntry) + 1); - CEntry[high(CEntry)].ID := ID; - CEntry[high(CEntry)].Text := Text; + SetLength (EntryConst, Length(EntryConst) + 1); + EntryConst[high(EntryConst)].ID := ID; + EntryConst[high(EntryConst)].Text := Text; end; {** @@ -267,11 +267,11 @@ procedure TLanguage.ChangeConst(const ID: AnsiString; const Text: UTF8String); var I: Integer; begin - for I := 0 to high(CEntry) do + for I := 0 to high(EntryConst) do begin - if CEntry[I].ID = ID then + if EntryConst[I].ID = ID then begin - CEntry[I].Text := Text; + EntryConst[I].Text := Text; Break; end; end; diff --git a/unicode/src/base/UMain.pas b/unicode/src/base/UMain.pas index cc6ffc1d..b8ddf346 100644 --- a/unicode/src/base/UMain.pas +++ b/unicode/src/base/UMain.pas @@ -174,12 +174,6 @@ begin Log.LogStatus('Write Ini', 'Initialization'); Ini.Save; - // Load Languagefile - if (Params.Language <> -1) then - Language.ChangeLanguage(ILanguage[Params.Language]) - else - Language.ChangeLanguage(ILanguage[Ini.Language]); - Log.BenchmarkEnd(1); Log.LogBenchmark('Loading Ini', 1); |