Skip to content

Commit

Permalink
Added French translation available in Options
Browse files Browse the repository at this point in the history
  • Loading branch information
NeeeeB committed Oct 11, 2017
1 parent 3a7909e commit 3285125
Show file tree
Hide file tree
Showing 6 changed files with 2,348 additions and 22 deletions.
35 changes: 27 additions & 8 deletions Main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object Frm_Editor: TFrm_Editor
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'GameList Editor'
ClientHeight = 667
ClientHeight = 688
ClientWidth = 1210
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Expand Down Expand Up @@ -5319,10 +5319,9 @@ object Frm_Editor: TFrm_Editor
object Lbl_NbGamesFound: TLabel
Left = 626
Top = 197
Width = 87
Width = 3
Height = 13
Alignment = taCenter
Caption = 'xxx games found.'
end
object Lbl_SelectSystem: TLabel
Left = 32
Expand Down Expand Up @@ -6679,19 +6678,19 @@ object Frm_Editor: TFrm_Editor
OnClick = Btn_ChangeImageClick
end
object Btn_SetDefaultPicture: TButton
Left = 600
Left = 584
Top = 286
Width = 139
Width = 169
Height = 25
Caption = 'Change Picture to default'
Enabled = False
TabOrder = 20
OnClick = Btn_SetDefaultPictureClick
end
object Btn_ChangeAll: TButton
Left = 571
Left = 547
Top = 315
Width = 193
Width = 241
Height = 25
Caption = 'Change all missing pictures to default'
Enabled = False
Expand Down Expand Up @@ -6857,6 +6856,7 @@ object Frm_Editor: TFrm_Editor
Top = 208
end
object MainMenu: TMainMenu
AutoHotkeys = maManual
Left = 104
Top = 264
object Mnu_File: TMenuItem
Expand Down Expand Up @@ -7092,6 +7092,25 @@ object Frm_Editor: TFrm_Editor
OnClick = Mnu_ThemeClick
end
end
object N4: TMenuItem
Caption = '-'
end
object Mnu_Language: TMenuItem
Caption = 'Language'
object Mnu_Lang1: TMenuItem
AutoCheck = True
Caption = 'English'
RadioItem = True
OnClick = Mnu_LangClick
end
object Mnu_Lang2: TMenuItem
Tag = 1
AutoCheck = True
Caption = 'French'
RadioItem = True
OnClick = Mnu_LangClick
end
end
end
object Mnu_Help: TMenuItem
Caption = 'Help'
Expand All @@ -7111,7 +7130,7 @@ object Frm_Editor: TFrm_Editor
Left = 176
Top = 208
Bitmap = {
494C010101000800640010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010101000800700010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
78 changes: 65 additions & 13 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ interface
tnWindows10Dark,
tnWindowsBasic );

//enum pour les langues
TLangName = ( lnEnglish,
lnFrench );

//Objet stockant uniquement le type système (enum) pour
//combobox systems, permet de retrouver facile l'image et le nom du systeme
TSystemKindObject = class
Expand Down Expand Up @@ -245,7 +249,11 @@ TFrm_Editor = class(TForm)
Chk_Favorite: TCheckBox;
Cbx_Hidden: TComboBox;
Cbx_Favorite: TComboBox;
Mnu_Theme17: TMenuItem;
Mnu_Theme17: TMenuItem;
N4: TMenuItem;
Mnu_Language: TMenuItem;
Mnu_Lang1: TMenuItem;
Mnu_Lang2: TMenuItem;

procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
Expand Down Expand Up @@ -279,10 +287,11 @@ TFrm_Editor = class(TForm)
procedure Mnu_ShowTipsClick(Sender: TObject);
procedure Mnu_PiPromptsClick(Sender: TObject);
procedure Mnu_ConfigSSHClick(Sender: TObject);
procedure Mnu_LangClick(Sender: TObject);

private

FThemeNumber: Integer;
FThemeNumber, FLanguage: Integer;
FRootPath: string;
FRootRomsPath: string;
FRootImagesPath: string;
Expand All @@ -309,18 +318,19 @@ TFrm_Editor = class(TForm)
procedure LoadSystemLogo( aPictureName: string );
procedure DeleteGame;
procedure DeleteGamePicture;
procedure CheckThemeMenuItem( aNumber: Integer );
procedure CheckMenuItem( aNumber: Integer; aLang: Boolean = False );
procedure RemoveRegionFromGameName( aGame: TGame; aStartPos: Integer );
procedure ConvertFieldsCase( aGame: TGame; aUnique: Boolean = False;
aUp: Boolean = False );
procedure StopOrStartES( aStop, aRecal: Boolean );

function getSystemKind: TSystemKind;
function getCurrentFolderName: string;
function getSystemKind: TSystemKind;
function getCurrentFolderName: string;
function GetCurrentLogoName: string;
function BuildGamesList( const aPathToFile: string ): TObjectList<TGame>;
function FormatDateFromString( const aDate: string; aIso: Boolean = False ): string;
function GetThemeEnum( aNumber: Integer ): TThemeName;
procedure StopOrStartES( aStop, aRecal: Boolean );
function GetLangEnum( aNumber: Integer ): TLangName;

end;

Expand Down Expand Up @@ -365,9 +375,11 @@ TFrm_Editor = class(TForm)
Cst_IniRecalPwd = 'SSHRecalPwd';
Cst_IniRetroLogin = 'SSHRetroLogin';
Cst_IniRetroPwd = 'SSHRetroPwd';
Cst_IniLanguage = 'Language';
Cst_GenesisLogoName = 'genesis.png';
Cst_ThemeNumber = 'ThemeNumber';
Cst_MenuTheme = 'Mnu_Theme';
Cst_MenuLang = 'Mnu_Lang';
Cst_PlinkCommand = '/C plink -v ';
Cst_PlinkCommandRecal = '@recalbox -pw ';
Cst_PlinkCommandRetro = '@retropie -pw ';
Expand Down Expand Up @@ -468,6 +480,11 @@ implementation
'Windows10 Dark',
'Windows' );

//tableau de liaison enum langues / noms langues
Cst_LangNameStr: array[TLangName] of string =
( 'en',
'fr' );

//tableau de liaison enum systemes / noms systems affichés
Cst_SystemKindStr: array[TSystemKind] of string =
( Rst_SystemKindNES,
Expand Down Expand Up @@ -833,12 +850,12 @@ procedure TFrm_Editor.LoadFromIni;
Mnu_ShowTips.Checked:= FShowTips;

FThemeNumber:= FileIni.ReadInteger( Cst_IniOptions, Cst_ThemeNumber, 5 );
FLanguage:= FileIni.ReadInteger( Cst_IniOptions, Cst_IniLanguage, 0 );

FRecalLogin:= FileIni.ReadString( Cst_IniOptions, Cst_IniRecalLogin, Cst_RecalLogin);
FRecalPwd:= FileIni.ReadString( Cst_IniOptions, Cst_IniRecalPwd, Cst_RecalPwd);
FRetroLogin:= FileIni.ReadString( Cst_IniOptions, Cst_IniRetroLogin, Cst_RetroLogin);
FRetroPwd:= FileIni.ReadString( Cst_IniOptions, Cst_IniRetroPwd, Cst_RetroPwd);

finally
FileIni.Free;
end;
Expand All @@ -858,6 +875,7 @@ procedure TFrm_Editor.SaveToIni;
FileIni.WriteBool( Cst_IniOptions, Cst_ShowTips, FShowTips );
FileIni.WriteBool( Cst_IniOptions, Cst_IniPiPrompts, FPiPrompts );
FileIni.WriteInteger( Cst_IniOptions, Cst_ThemeNumber, FThemeNumber );
FileIni.WriteInteger( Cst_IniOptions, Cst_IniLanguage, FLanguage );
FileIni.WriteString( Cst_IniOptions, Cst_IniRecalLogin, FRecalLogin);
FileIni.WriteString( Cst_IniOptions, Cst_IniRecalPwd, FRecalPwd);
FileIni.WriteString( Cst_IniOptions, Cst_IniRetroLogin, FRetroLogin);
Expand All @@ -881,6 +899,20 @@ function TFrm_Editor.GetThemeEnum( aNumber: Integer ): TThemeName;
end;
end;

//Recup de l'enum de la langue en fonction de l'entier du fichier ini
function TFrm_Editor.GetLangEnum( aNumber: Integer ): TLangName;
var
_LangName: TLangName;
begin
Result:= lnEnglish;
for _LangName:= Low( TLangName ) to High( TLangName ) do begin
if ( aNumber = Ord( _LangName ) ) then begin
Result:= _LangName;
Break;
end;
end;
end;

//A l'ouverture du programme
procedure TFrm_Editor.FormCreate(Sender: TObject);
begin
Expand All @@ -897,7 +929,10 @@ procedure TFrm_Editor.FormShow(Sender: TObject);
var
Frm_Help: TFrm_Help;
begin
CheckThemeMenuItem( Succ( FThemeNumber ) );
UseLanguage( Cst_LangNameStr[GetLangEnum( FLanguage )] );
RetranslateComponent( Self );
CheckMenuItem( Succ( FThemeNumber ) );
CheckMenuItem( Succ( FLanguage ), True );
if FShowTips then begin
//Affiche la fenêtre "Help"
Frm_Help:= TFrm_Help.Create(nil);
Expand All @@ -911,13 +946,14 @@ procedure TFrm_Editor.FormShow(Sender: TObject);
Lbx_Games.SetFocus;
end;

//Pour checker le menuitem du numéro de thème récupéré depuis le fichier ini
procedure TFrm_Editor.CheckThemeMenuItem( aNumber: Integer );
//Pour checker le menuitem du numéro de thème ou langue récupéré depuis le fichier ini
procedure TFrm_Editor.CheckMenuItem( aNumber: Integer; aLang: Boolean = False );
var
_MenuItem: TMenuItem;
_CompName: string;
begin
_CompName:= Cst_MenuTheme + IntToStr( aNumber );
if aLang then _CompName:= Cst_MenuLang + IntToStr( aNumber )
else _CompName:= Cst_MenuTheme + IntToStr( aNumber );
_MenuItem:= ( FindComponent( _CompName ) as TMenuItem ) ;
_MenuItem.Checked:= True;
end;
Expand Down Expand Up @@ -1088,6 +1124,7 @@ procedure TFrm_Editor.BuildSystemsList;
Lbl_Filter.Enabled:= Cbx_Systems.Enabled;
Cbx_Systems.ItemIndex:= 0;
EnableControls( True );
Cbx_Filter.ItemIndex:= 0;
LoadGamesList( getCurrentFolderName );

//On remet le curseur par défaut
Expand Down Expand Up @@ -1830,15 +1867,17 @@ procedure TFrm_Editor.SaveChangesToGamelist;
_Node.AddChild( Cst_Hidden );
_NodeAdded:= True;
end;
_Node.ChildNodes.Nodes[Cst_Hidden].Text:= LowerCase( Cbx_Hidden.Items[Cbx_Hidden.ItemIndex] );
if ( Cbx_Hidden.ItemIndex = 0 ) then _Node.ChildNodes.Nodes[Cst_Hidden].Text:= Cst_False
else _Node.ChildNodes.Nodes[Cst_Hidden].Text:= Cst_True;
_Game.FHidden:= Cbx_Hidden.ItemIndex;
end;
if not ( _Game.FFavorite = Cbx_Favorite.ItemIndex ) then begin
if not ( NodeExists( _Node, Cst_Favorite ) ) then begin
_Node.AddChild( Cst_Favorite );
_NodeAdded:= True;
end;
_Node.ChildNodes.Nodes[Cst_Favorite].Text:= LowerCase( Cbx_Favorite.Items[Cbx_Favorite.ItemIndex] );
if ( Cbx_Favorite.ItemIndex = 0 ) then _Node.ChildNodes.Nodes[Cst_Favorite].Text:= Cst_False
else _Node.ChildNodes.Nodes[Cst_Favorite].Text:= Cst_True;
_Game.FFavorite:= Cbx_Favorite.ItemIndex;
end;

Expand Down Expand Up @@ -2159,6 +2198,7 @@ procedure TFrm_Editor.Mnu_HelpClick(Sender: TObject);
end;
end;

//au click sur le menu item disable pi prompts
procedure TFrm_Editor.Mnu_PiPromptsClick(Sender: TObject);
begin
FPiPrompts:= Mnu_PiPrompts.Checked;
Expand Down Expand Up @@ -2307,6 +2347,18 @@ procedure TFrm_Editor.Mnu_ThemeClick(Sender: TObject);
FThemeNumber:= ( Sender as TMenuItem ).Tag;
end;

//Choix de la langue
procedure TFrm_Editor.Mnu_LangClick(Sender: TObject);
var
index: Integer;
begin
index:= Cbx_Filter.ItemIndex;
UseLanguage( Cst_LangNameStr[GetLangEnum( ( Sender as TMenuItem).Tag )] );
FLanguage:= ( Sender as TMenuItem ).Tag;
RetranslateComponent( Self );
Cbx_Filter.ItemIndex:= index;
end;

//Click sur le menuitem "Quit"
procedure TFrm_Editor.Mnu_QuitClick(Sender: TObject);
begin
Expand Down
3 changes: 2 additions & 1 deletion Resources/Settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ ThemeNumber=5
SSHRecalLogin=root
SSHRecalPwd=recalboxroot
SSHRetroLogin=pi
SSHRetroPwd=raspberry
SSHRetroPwd=raspberry
Language=en
Loading

0 comments on commit 3285125

Please sign in to comment.