Skip to content

Commit

Permalink
implement language setting (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie authored May 3, 2022
1 parent e72e33b commit a8ee39c
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 52 deletions.
19 changes: 19 additions & 0 deletions HandheldCompanion/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Serilog;
using Serilog.Extensions.Logging;
using System;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Windows;
Expand All @@ -25,6 +26,24 @@ public partial class App : Application
[STAThread]
private void Main(object sender, StartupEventArgs Arguments)
{
string CurrentCulture = HandheldCompanion.Properties.Settings.Default.CurrentCulture;
CultureInfo culture = CultureInfo.CurrentCulture;

switch (CurrentCulture)
{
default:
break;
case "fr-FR":
case "en-US":
case "zh-CN":
case "zh-Hant":
culture = new CultureInfo(CurrentCulture);
break;
}

Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

if (mutex.WaitOne(TimeSpan.Zero, true))
{
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
Expand Down
36 changes: 36 additions & 0 deletions HandheldCompanion/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 25 additions & 27 deletions HandheldCompanion/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,18 @@
</data>
<data name="MainWindow_OK" xml:space="preserve">
<value>OK</value>
<comment>update</comment>
</data>
<data name="MainWindow_serviceDeploy" xml:space="preserve">
<value>Déployer le service</value>
</data>
<data name="MainWindow_ServiceManager" xml:space="preserve">
<value>Service manager</value>
<comment>update</comment>
<value>Gestionnaire de service</value>
</data>
<data name="MainWindow_ServiceManagerStartIssue" xml:space="preserve">
<value>Oups. There was an issue while we tried to start the service.</value>
<comment>update</comment>
<value>Oups. Il y a eu un problème lorsque nous avons essayé de démarrer le service.</value>
</data>
<data name="MainWindow_ServiceManagerStopIssue" xml:space="preserve">
<value>Oups. There was an issue while we tried to stop the service.</value>
<comment>update</comment>
<value>Oups. Il y a eu un problème lorsque nous avons essayé d'arrêter le service.</value>
</data>
<data name="MainWindow_serviceRemove" xml:space="preserve">
<value>Supprimer le service</value>
Expand Down Expand Up @@ -428,31 +424,25 @@
<value>Modifier l'anti-zone morte, en pourcentage</value>
</data>
<data name="ProfilesPage_AreYouSureDelete1" xml:space="preserve">
<value>Are you sure you want to delete</value>
<comment>update</comment>
<value>Êtes-vous sûr de vouloir supprimer</value>
</data>
<data name="ProfilesPage_AreYouSureDelete2" xml:space="preserve">
<value>This item will be deleted immediatly. You can't undo this action.</value>
<comment>update</comment>
<value>Cet élément sera supprimé immédiatement. Vous ne pouvez pas annuler cette action.</value>
</data>
<data name="ProfilesPage_AreYouSureOverwrite1" xml:space="preserve">
<value>Are you sure you want to overwrite</value>
<comment>update</comment>
<value>Etes-vous sûr de vouloir écraser</value>
</data>
<data name="ProfilesPage_AreYouSureOverwrite2" xml:space="preserve">
<value>This item will be overwriten. You can't undo this action.</value>
<comment>update</comment>
<value>Cet élément sera écrasé. Vous ne pouvez pas annuler cette action.</value>
</data>
<data name="ProfilesPage_Cancel" xml:space="preserve">
<value>Cancel</value>
<comment>update</comment>
<value>Annuler</value>
</data>
<data name="ProfilesPage_CreateNewProfile" xml:space="preserve">
<value>Créer un nouveau profil</value>
</data>
<data name="ProfilesPage_Delete" xml:space="preserve">
<value>Delete</value>
<comment>update</comment>
<value>Supprimer</value>
</data>
<data name="ProfilesPage_DeleteProfile" xml:space="preserve">
<value>Supprimer le profil</value>
Expand Down Expand Up @@ -501,7 +491,6 @@
</data>
<data name="ProfilesPage_OK" xml:space="preserve">
<value>OK</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_ProfileDetails" xml:space="preserve">
<value>Détails du profil</value>
Expand All @@ -525,12 +514,10 @@
<value>Paramètres du profil</value>
</data>
<data name="ProfilesPage_ProfileUpdated1" xml:space="preserve">
<value>Profile updated</value>
<comment>update</comment>
<value>Profil mis à jour</value>
</data>
<data name="ProfilesPage_ProfileUpdated2" xml:space="preserve">
<value>was updated.</value>
<comment>update</comment>
<value>a été mis à jour.</value>
</data>
<data name="ProfilesPage_Roll" xml:space="preserve">
<value>Roulis</value>
Expand Down Expand Up @@ -572,15 +559,26 @@
<value>Lacet</value>
</data>
<data name="ProfilesPage_Yes" xml:space="preserve">
<value>Yes</value>
<comment>update</comment>
<value>Oui</value>
</data>
<data name="ServiceDescription" xml:space="preserve">
<value>Fournit une prise en charge du gyroscope et de l'accéléromètre aux ordinateurs de jeu portables Windows par le biais d'un contrôleur virtuel. Si le service est activé, le contrôleur intégré sera masqué pour les applications en dehors de la liste blanche. Si le service est désactivé, le contrôleur embarqué ne sera plus caché et le contrôleur virtuel sera désactivé</value>
</data>
<data name="ServiceName" xml:space="preserve">
<value>Controller Service</value>
</data>
<data name="SettingsPage_AppLanguage" xml:space="preserve">
<value>Langue</value>
</data>
<data name="SettingsPage_AppLanguageDesc" xml:space="preserve">
<value>La langue de l'application</value>
</data>
<data name="SettingsPage_AppLanguageWarning" xml:space="preserve">
<value>Redémarrage nécessaire</value>
</data>
<data name="SettingsPage_AppLanguageWarningDesc" xml:space="preserve">
<value>Pour que les modifications soient prises en compte, veuillez redémarrer l'application</value>
</data>
<data name="SettingsPage_AppTheme" xml:space="preserve">
<value>Thème de l'application</value>
</data>
Expand Down Expand Up @@ -663,7 +661,7 @@
<value>Mises à jour disponibles</value>
</data>
<data name="SettingsPage_UpdateCheck" xml:space="preserve">
<value>Vérification des mises à jour..</value>
<value>Vérification des mises à jour...</value>
</data>
<data name="SettingsPage_UpToDate" xml:space="preserve">
<value>Vous êtes à jour</value>
Expand Down
26 changes: 12 additions & 14 deletions HandheldCompanion/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -221,22 +221,18 @@
</data>
<data name="MainWindow_OK" xml:space="preserve">
<value>OK</value>
<comment>update</comment>
</data>
<data name="MainWindow_serviceDeploy" xml:space="preserve">
<value>Deploy service</value>
</data>
<data name="MainWindow_ServiceManager" xml:space="preserve">
<value>Service manager</value>
<comment>update</comment>
</data>
<data name="MainWindow_ServiceManagerStartIssue" xml:space="preserve">
<value>Oups. There was an issue while we tried to start the service.</value>
<comment>update</comment>
</data>
<data name="MainWindow_ServiceManagerStopIssue" xml:space="preserve">
<value>Oups. There was an issue while we tried to stop the service.</value>
<comment>update</comment>
</data>
<data name="MainWindow_serviceRemove" xml:space="preserve">
<value>Remove service</value>
Expand Down Expand Up @@ -429,30 +425,24 @@
</data>
<data name="ProfilesPage_AreYouSureDelete1" xml:space="preserve">
<value>Are you sure you want to delete</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_AreYouSureDelete2" xml:space="preserve">
<value>This item will be deleted immediatly. You can't undo this action.</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_AreYouSureOverwrite1" xml:space="preserve">
<value>Are you sure you want to overwrite</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_AreYouSureOverwrite2" xml:space="preserve">
<value>This item will be overwriten. You can't undo this action.</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_Cancel" xml:space="preserve">
<value>Cancel</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_CreateNewProfile" xml:space="preserve">
<value>Create a new profile</value>
</data>
<data name="ProfilesPage_Delete" xml:space="preserve">
<value>Delete</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_DeleteProfile" xml:space="preserve">
<value>Delete profile</value>
Expand Down Expand Up @@ -501,7 +491,6 @@
</data>
<data name="ProfilesPage_OK" xml:space="preserve">
<value>OK</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_ProfileDetails" xml:space="preserve">
<value>Profile details</value>
Expand All @@ -526,11 +515,9 @@
</data>
<data name="ProfilesPage_ProfileUpdated1" xml:space="preserve">
<value>Profile updated</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_ProfileUpdated2" xml:space="preserve">
<value>was updated.</value>
<comment>update</comment>
</data>
<data name="ProfilesPage_Roll" xml:space="preserve">
<value>Roll</value>
Expand Down Expand Up @@ -573,7 +560,6 @@
</data>
<data name="ProfilesPage_Yes" xml:space="preserve">
<value>Yes</value>
<comment>update</comment>
</data>
<data name="Properties.Resources.ControllerPage_Disconnect" xml:space="preserve">
<value>Properties.Resources.ControllerPage_Disconnect</value>
Expand All @@ -584,6 +570,18 @@
<data name="ServiceName" xml:space="preserve">
<value>Controller Service</value>
</data>
<data name="SettingsPage_AppLanguage" xml:space="preserve">
<value>Language</value>
</data>
<data name="SettingsPage_AppLanguageDesc" xml:space="preserve">
<value>The application language</value>
</data>
<data name="SettingsPage_AppLanguageWarning" xml:space="preserve">
<value>Restart required</value>
</data>
<data name="SettingsPage_AppLanguageWarningDesc" xml:space="preserve">
<value>In order for the changes to take effect, please restart the application</value>
</data>
<data name="SettingsPage_AppTheme" xml:space="preserve">
<value>Application theme</value>
</data>
Expand Down
14 changes: 13 additions & 1 deletion HandheldCompanion/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions HandheldCompanion/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
<Setting Name="OverlayTrackpadsSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">250</Value>
</Setting>
<Setting Name="CurrentCulture" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
39 changes: 30 additions & 9 deletions HandheldCompanion/Views/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,35 @@
</ui:SimpleStackPanel>
</DockPanel>

<ComboBox Name="cB_Theme" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectionChanged="cB_Theme_SelectionChanged"
MouseEnter="Scrolllock_MouseEnter"
MouseLeave="Scrolllock_MouseLeave">
<ComboBoxItem Content="{x:Static resx:Resources.SettingsPage_ThemeLight}"/>
<ComboBoxItem Content="{x:Static resx:Resources.SettingsPage_ThemeDark}"/>
</ComboBox>
<ui:RadioButtons Name="cB_Theme" Grid.Column="1" HorizontalAlignment="Right" MaxColumns="2" SelectionChanged="cB_Theme_SelectionChanged">
<Label Content="{x:Static resx:Resources.SettingsPage_ThemeLight}"/>
<Label Content="{x:Static resx:Resources.SettingsPage_ThemeDark}"/>
</ui:RadioButtons>
</Grid>
</Border>

<!-- Application language -->
<Border
Padding="15,12,12,12"
CornerRadius="{DynamicResource ControlCornerRadius}"
Background="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" MinWidth="200"></ColumnDefinition>
<ColumnDefinition Width="3*" MinWidth="120"></ColumnDefinition>
</Grid.ColumnDefinitions>

<DockPanel>
<ui:FontIcon FontFamily="{DynamicResource SymbolThemeFontFamily}" Glyph="&#xF2B7;" Height="40" HorizontalAlignment="Center"/>

<ui:SimpleStackPanel VerticalAlignment="Center" Margin="12,0,0,0">
<TextBlock Text="{x:Static resx:Resources.SettingsPage_AppLanguage}" FontSize="14"/>
<TextBlock Text="{x:Static resx:Resources.SettingsPage_AppLanguageDesc}" Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}" FontSize="12" TextWrapping="Wrap"/>
</ui:SimpleStackPanel>
</DockPanel>

<ui:RadioButtons Name="cB_Language" Grid.Column="1" HorizontalAlignment="Right" MaxColumns="2" SelectionChanged="cB_Language_SelectionChanged"/>
</Grid>
</Border>
</ui:SimpleStackPanel>
Expand Down Expand Up @@ -226,9 +249,7 @@
</ui:SimpleStackPanel>
</DockPanel>

<ComboBox Name="cB_StartupType" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectionChanged="cB_StartupType_SelectionChanged"
MouseEnter="Scrolllock_MouseEnter"
MouseLeave="Scrolllock_MouseLeave"/>
<ui:RadioButtons Name="cB_StartupType" Grid.Column="1" HorizontalAlignment="Right" MaxColumns="1" SelectionChanged="cB_StartupType_SelectionChanged" />
</Grid>
</Border>

Expand Down
Loading

0 comments on commit a8ee39c

Please sign in to comment.