1- using Microsoft . Extensions . Logging ;
1+ using System . Globalization ;
2+ using Microsoft . Extensions . Logging ;
23using System . Net . Sockets ;
34using VRCFaceTracking ;
45using VRCFTPicoModule . Utils ;
6+ using static VRCFTPicoModule . Utils . Localization ;
57
68namespace VRCFTPicoModule ;
79
@@ -18,40 +20,47 @@ public class VRCFTPicoModule : ExtTrackingModule
1820
1921 public override ( bool eyeSuccess , bool expressionSuccess ) Initialize ( bool eyeAvailable , bool expressionAvailable )
2022 {
21- Logger . LogInformation ( "Starting initialization" ) ;
23+ Localization . Initialize ( CultureInfo . CurrentUICulture . Name ) ;
24+ Logger . LogInformation ( T ( "start-init" ) ) ;
2225 _trackingAvailable = ( eyeAvailable , expressionAvailable ) ;
2326 var initializationResult = InitializeAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
24-
25- if ( ! initializationResult . Item1 || ! initializationResult . Item2 )
26- UpdateModuleInfo ( ) ;
27+ UpdateModuleInfo ( initializationResult ) ;
2728
2829 return initializationResult ;
2930 }
3031
3132 private async Task < ( bool eyeSuccess , bool expressionSuccess ) > InitializeAsync ( )
3233 {
33- Logger . LogDebug ( "Initializing UDP Clients on ports: {0}" , string . Join ( ", " , Ports ) ) ;
34+ Logger . LogDebug ( T ( "initializing-udp-clients" ) , string . Join ( ", " , Ports ) ) ;
3435
3536 var portIndex = await ListenOnPorts ( ) ;
3637 if ( portIndex == - 1 ) return ( false , false ) ;
3738
3839 _port = Ports [ portIndex ] ;
3940 _udpClient = new UdpClient ( _port ) ;
40- Logger . LogInformation ( "Using port: {0}" , _port ) ;
41+ Logger . LogInformation ( T ( "using- port" ) , _port ) ;
4142
4243 if ( ! _trackingAvailable . Item1 )
43- Logger . LogInformation ( "Eye tracking is disabled") ;
44+ Logger . LogInformation ( T ( "eye- tracking- disabled") ) ;
4445 if ( ! _trackingAvailable . Item2 )
45- Logger . LogInformation ( "Expression tracking is disabled") ;
46+ Logger . LogInformation ( T ( "expression- tracking- disabled") ) ;
4647
4748 _updater = new Updater ( _udpClient , Logger , _port == Ports [ 1 ] , _trackingAvailable ) ;
4849
4950 return _trackingAvailable ;
5051 }
5152
52- private void UpdateModuleInfo ( )
53+ private void UpdateModuleInfo ( ( bool , bool ) initializationResult )
5354 {
54- ModuleInformation . Name = "PICO Connect" ;
55+ var moduleProtocol = _port == Ports [ 1 ] ? $ " [{ T ( "legacy-protocol" ) } ]" : "" ;
56+ var moduleTrackingStatus = initializationResult switch
57+ {
58+ { Item1 : true , Item2 : true } => T ( "full-face-tracking" ) ,
59+ { Item1 : true , Item2 : false } => T ( "eye-tracking" ) ,
60+ { Item1 : false , Item2 : true } => T ( "expression-tracking" ) ,
61+ _ => ""
62+ } ;
63+ ModuleInformation . Name = "PICO / " + moduleTrackingStatus + moduleProtocol ;
5564 var stream = GetType ( ) . Assembly . GetManifestResourceStream ( "VRCFTPicoModule.Assets.pico.png" ) ;
5665 ModuleInformation . StaticImages = stream != null ? [ stream ] : ModuleInformation . StaticImages ;
5766 }
@@ -75,18 +84,15 @@ private async Task<int> ListenOnPorts()
7584 }
7685 catch ( Exception ex )
7786 {
78- Logger . LogError ( "Initialization failed, exception: {0}" , ex ) ;
87+ Logger . LogError ( T ( "init- failed" ) , ex ) ;
7988 }
8089
8190 return - 1 ;
8291 }
8392
8493 public override void Update ( )
8594 {
86- if ( _updater == null )
87- return ;
88-
89- _updater . Update ( Status ) ;
95+ _updater ? . Update ( Status ) ;
9096 }
9197
9298 public override void Teardown ( )
0 commit comments