88using System . Security . Cryptography ;
99
1010namespace Olympus {
11- public class CmdUpdateAllMods : Cmd < string , bool , string , bool , IEnumerator > {
11+ public class CmdUpdateAllMods : Cmd < string , bool , string , bool , string , IEnumerator > {
1212 private static readonly Logger log = new Logger ( nameof ( CmdUpdateAllMods ) ) ;
1313
1414 public override bool Taskable => true ;
1515
16- public override IEnumerator Run ( string root , bool onlyEnabled , string mirrorPreferences , bool apiMirror ) {
17- yield return "Downloading mod versions list..." ;
16+ private static readonly Dictionary < string , Dictionary < string , string > > translations = new Dictionary < string , Dictionary < string , string > > {
17+ {
18+ "en" , new Dictionary < string , string > {
19+ { "downloading" , "Downloading mod versions list" } ,
20+ { "checking" , "Checking for outdated mods" } ,
21+ { "updating" , "Updating" } ,
22+ { "installing" , "installing update" } ,
23+ { "finished_noop" , "Update check finished.\n No updates were found." } ,
24+ { "finished" , "Update successful!\n The following mods were updated:" } ,
25+ { "checksum" , "verifying checksum" }
26+ }
27+ } , {
28+ "fr" , new Dictionary < string , string > {
29+ { "downloading" , "Téléchargement de la liste des mods" } ,
30+ { "checking" , "Vérification des mises à jour" } ,
31+ { "updating" , "Mise à jour" } ,
32+ { "installing" , "installation en cours" } ,
33+ { "finished_noop" , "La vérification est terminée.\n Aucune mise à jour n'a été trouvée." } ,
34+ { "finished" , "Mise à jour terminée !\n Les mods suivants ont été mis à jour :" } ,
35+ { "checksum" , "vérification de la somme de contrôle" }
36+ }
37+ } ,
38+ } ;
39+
40+ private static string langGet ( string lang , string key ) {
41+ if ( lang . Equals ( "ne" ) ) {
42+ char [ ] charArray = translations [ "en" ] [ key ] . ToCharArray ( ) ;
43+ Array . Reverse ( charArray ) ;
44+ return new string ( charArray ) ;
45+ }
46+ return translations [ lang ] [ key ] ;
47+ }
48+
49+
50+
51+ public override IEnumerator Run ( string root , bool onlyEnabled , string mirrorPreferences , bool apiMirror , string lang ) {
52+ yield return $ "{ langGet ( lang , "downloading" ) } ...";
1853 Dictionary < string , ModUpdateInfo > modVersionList = downloadModUpdateList ( apiMirror ) ;
1954
20- yield return "Checking for outdated mods ...";
55+ yield return $ " { langGet ( lang , "checking" ) } ...";
2156
2257 Dictionary < ModUpdateInfo , CmdModList . ModInfo > updates = new Dictionary < ModUpdateInfo , CmdModList . ModInfo > ( ) ;
2358
@@ -30,7 +65,7 @@ public override IEnumerator Run(string root, bool onlyEnabled, string mirrorPref
3065
3166 foreach ( CmdModList . ModInfo info in new EnumeratorEnumerator { Enumerator = new CmdModList ( ) . Run ( root , readYamls : true , computeHashes : true , onlyUpdatable : true , onlyEnabled ) } ) {
3267 processedCount ++ ;
33- yield return "Checking for outdated mods (" + ( int ) Math . Round ( processedCount * 100f / totalCount ) + "%)..." ;
68+ yield return $ " { langGet ( lang , "checking" ) } (" + ( int ) Math . Round ( processedCount * 100f / totalCount ) + "%)..." ;
3469
3570 if ( info . Hash != null && modVersionList . ContainsKey ( info . Name ) ) {
3671 log . Debug ( $ "Mod { info . Name } : installed hash { info . Hash } , latest hash(es) { string . Join ( ", " , modVersionList [ info . Name ] . xxHash ) } ") ;
@@ -44,7 +79,7 @@ public override IEnumerator Run(string root, bool onlyEnabled, string mirrorPref
4479
4580 int updatingMod = 1 ;
4681 foreach ( KeyValuePair < ModUpdateInfo , CmdModList . ModInfo > update in updates ) {
47- string messagePrefix = $ "[{ updatingMod } /{ updates . Count } ] Updating { update . Value . Name } ";
82+ string messagePrefix = $ "[{ updatingMod } /{ updates . Count } ] { langGet ( lang , "updating" ) } { update . Value . Name } ";
4883
4984 yield return messagePrefix + "..." ;
5085
@@ -54,17 +89,17 @@ public override IEnumerator Run(string root, bool onlyEnabled, string mirrorPref
5489 yield return message ;
5590 }
5691
57- yield return messagePrefix + ": installing update " ;
92+ yield return messagePrefix + $ ": { langGet ( lang , "installing" ) } ";
5893 installModUpdate ( update . Key , update . Value , tempZip ) ;
5994
6095 updatingMod ++ ;
6196 }
6297
6398 // The last yielded message might be displayed as a recap popup by Olympus when relevant.
6499 if ( updates . Count == 0 ) {
65- yield return "Update check finished. \n No updates were found." ;
100+ yield return langGet ( lang , "finished_noop" ) ;
66101 } else {
67- yield return "Update successful! \n The following mods were updated:"
102+ yield return langGet ( lang , "finished" )
68103 + updates . Values . Aggregate ( "" , ( a , b ) => $ "{ a } \n - { b . Name } ") ;
69104 }
70105 }
0 commit comments