Skip to content

Commit

Permalink
Internationalization - Config list (#1940)
Browse files Browse the repository at this point in the history
* Added i18n for config list

* Move cells and cells into own files

* Fix linter erros

* Fix playwright tests

* Update the github workflow to prevent double execution

* Translate missing waiting

* Fix linter issue
  • Loading branch information
DocMoebiuz authored Feb 7, 2025
1 parent c91fd53 commit 4202cf6
Show file tree
Hide file tree
Showing 28 changed files with 739 additions and 336 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Playwright Tests
on:
push:
branches: [ mf2025/* ]
pull_request:
branches: [ main, mf2025/main ]
jobs:
Expand Down
87 changes: 87 additions & 0 deletions Base/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.Linq;

namespace MobiFlight.Base
{
public class Settings
{
public bool ArcazeSupportEnabled { get; set; }
public bool AutoRetrigger { get; set; }
public bool AutoRun { get; set; }
public bool AutoLoadLinkedConfig { get; set; }
public bool BetaUpdates { get; set; }
public bool CommunityFeedback { get; set; }
public bool EnableJoystickSupport { get; set; }
public bool EnableMidiSupport { get; set; }
public string ExcludedJoysticks { get; set; }
public string ExcludedMidiBoards { get; set; }
public bool FwAutoUpdateCheck { get; set; }
public bool HubHopAutoCheck { get; set; }
public string IgnoredComPortsList { get; set; }
public string Language { get; set; }
public bool LogEnabled { get; set; }
public bool LogJoystickAxis { get; set; }
public string LogLevel { get; set; }
public bool MinimizeOnAutoRun { get; set; }
public string ModuleSettings { get; set; }
public string[] RecentFiles { get; set; }
public int RecentFilesMaxCount { get; set; }
public int TestTimerInterval { get; set; }

internal Settings()
{
}

internal Settings(Properties.Settings settings)
{
ArcazeSupportEnabled = settings.ArcazeSupportEnabled;
AutoRetrigger = settings.AutoRetrigger;
AutoRun = settings.AutoRun;
AutoLoadLinkedConfig = settings.AutoLoadLinkedConfig;
BetaUpdates = settings.BetaUpdates;
CommunityFeedback = settings.CommunityFeedback;
EnableJoystickSupport = settings.EnableJoystickSupport;
EnableMidiSupport = settings.EnableMidiSupport;
ExcludedJoysticks = settings.ExcludedJoysticks;
ExcludedMidiBoards = settings.ExcludedMidiBoards;
FwAutoUpdateCheck = settings.FwAutoUpdateCheck;
HubHopAutoCheck = settings.HubHopAutoCheck;
IgnoredComPortsList = settings.IgnoredComPortsList;
Language = settings.Language;
LogEnabled = settings.LogEnabled;
LogJoystickAxis = settings.LogJoystickAxis;
LogLevel = settings.LogLevel;
MinimizeOnAutoRun = settings.MinimizeOnAutoRun;
ModuleSettings = settings.ModuleSettings;
// Skip: OfflineMode = settings.OfflineMode;
// Skip: PollInterval = settings.PollInterval;
RecentFiles = settings.RecentFiles.Cast<string>().ToArray();
RecentFilesMaxCount = settings.RecentFilesMaxCount;
TestTimerInterval = settings.TestTimerInterval;
// Properties.Settings.Default.AutoRetrigger = true;
// Properties.Settings.Default.AutoRun = true;
// Properties.Settings.Default.AutoLoadLinkedConfig = true;
// Properties.Settings.Default.BetaUpdates = true;
// Properties.Settings.Default.CommunityFeedback = true;
// Properties.Settings.Default.EnableJoystickSupport = true;
// Properties.Settings.Default.EnableMidiSupport = true;
// Properties.Settings.Default.ExcludedJoysticks
// Properties.Settings.Default.ExcludedMidiBoards
// Properties.Settings.Default.FwAutoUpdateCheck = true;
// Properties.Settings.Default.HubHopAutoCheck = true;
// Properties.Settings.Default.IgnoredComPortsList
// Properties.Settings.Default.Language = "en";
// Properties.Settings.Default.LogEnabled = true;
// Properties.Settings.Default.LogJoystickAxis = false;
// Properties.Settings.Default.LogLevel = "Debug";
// Properties.Settings.Default.MinimizeOnAutoRun = true;
// Properties.Settings.Default.ModuleSettings = true;
// Skip: Properties.Settings.Default.OfflineMode = false;
// Skip: Properties.Settings.Default.PollInterval = 100;
// Properties.Settings.Default.RecentFiles = new System.Collections.Specialized.StringCollection();
// Properties.Settings.Default.RecentFilesMaxCount = 10;
// Skip: Properties.Settings.Default.TestTimerInterval = 1000;
}


}
}
1 change: 1 addition & 0 deletions MobiFlightConnector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<Compile Include="Base\DPIUtil.cs" />
<Compile Include="Base\Extensions.cs" />
<Compile Include="Base\FullCacheInterface.cs" />
<Compile Include="Base\Settings.cs" />
<Compile Include="Base\i18n.cs" />
<Compile Include="Base\IDeviceConfig.cs" />
<Compile Include="Base\LogAppender\MessageExchangeAppender.cs" />
Expand Down
4 changes: 2 additions & 2 deletions UI/Dialogs/ConfigWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void Init(ExecutionManager executionManager, OutputConfigItem cfg)
testValuePanel1.TestModeStart += TestValuePanel_TestModeStart;
testValuePanel1.TestModeStop += TestValuePanel_TestModeEnd;
testValuePanel1.TestValueChanged += ModifierPanel1_ModifierChanged;
TestTimer.Interval = Settings.Default.TestTimerInterval;
TestTimer.Interval = Properties.Settings.Default.TestTimerInterval;
TestTimer.Tick += TestTimer_Tick;
modifierPanel1.ModifierChanged += ModifierPanel1_ModifierChanged;
}
Expand All @@ -135,7 +135,7 @@ private void ModifierPanel1_ModifierChanged(object sender, EventArgs e)

private void TestTimer_Tick(object sender, EventArgs e)
{
TestTimer.Interval = Settings.Default.TestTimerInterval;
TestTimer.Interval = Properties.Settings.Default.TestTimerInterval;
var value = config.TestValue.Clone() as ConnectorValue;
if (value == null) value = new ConnectorValue();

Expand Down
9 changes: 9 additions & 0 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ private void InitializeSettings()
{
UpgradeSettingsFromPreviousInstallation();
Properties.Settings.Default.SettingChanging += new System.Configuration.SettingChangingEventHandler(Default_SettingChanging);

Properties.Settings.Default.SettingsSaving += (s, e) =>
{
MessageExchange.Instance.Publish(new Settings(Properties.Settings.Default));
};

UpdateAutoLoadConfig();
RestoreAutoLoadConfig();
CurrentFilenameChanged += (s, e) => { UpdateAutoLoadMenu(); };
Expand All @@ -129,6 +135,9 @@ private void InitializeSettings()
// there are no recent files which
// could lead to a filename change
UpdateAutoLoadMenu();

// Send the current settings to the UI
MessageExchange.Instance.Publish(new Settings(Properties.Settings.Default));
}

public MainForm()
Expand Down
1 change: 1 addition & 0 deletions UI/Panels/Settings/GeneralPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected void InitializeLanguageComboBox()
languageOptions.Add(new ListItem() { Value = "", Label = "System Default" });
languageOptions.Add(new ListItem() { Value = "en-US", Label = "English" });
languageOptions.Add(new ListItem() { Value = "de-DE", Label = "Deutsch" });
languageOptions.Add(new ListItem() { Value = "es-ES", Label = "Español" });

languageComboBox.DataSource = languageOptions;
languageComboBox.DisplayMember = "Label";
Expand Down
2 changes: 1 addition & 1 deletion frontend/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
}
9 changes: 9 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"i18next-browser-languagedetector": "^8.0.2",
"i18next-http-backend": "^3.0.1",
"lodash-es": "^4.17.21",
"lucide-react": "^0.471.0",
Expand Down
44 changes: 44 additions & 0 deletions frontend/public/locales/de/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"ConfigList": {
"Toolbar" : {
"Search" : {
"Placeholder": "Einträge filtern..."
},
"Filter" : {
"Device": "Geräte",
"Type" : "Typen",
"Name" : "Namen",
"Selected" : "{{items}} ausgewählt",
"Clear" : "Filter zurücksetzen",
"NoResultsFound" : "Keine Ergebnisse gefunden."
},
"Reset": "Filter zurücksetzen"
},
"Header" : {
"Active": "Aktiv",
"Name": "Name / Beschreibung",
"Device": "Gerät",
"Component": "Komponente",
"Status": "Status",
"RawValue": "Rohwert",
"FinalValue": "Endwert",
"Actions": "Aktionen"
},
"Cell" : {
"Waiting" : "Warten"
},
"Table" : {
"NoResultsFound" : "Neue Konfiguration. Erstelle neue Einträge."
},
"Actions": {
"OutputConfigItem" : {
"Add": "Neue Ausgabe-Konfiguration",
"DefaultName": "Neue Ausgabe-Konfiguration"
},
"InputConfigItem" : {
"Add": "Neue Eingabe-konfiguration",
"DefaultName": "Neue Eingabe-Konfiguration"
}
}
}
}
44 changes: 41 additions & 3 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
{
"interpolation": "Hello {{name}}!",
"app": {
"greeting": "Hello MobiFlight user! Test!"
"ConfigList": {
"Toolbar" : {
"Search" : {
"Placeholder": "Filter items..."
},
"Filter" : {
"Device": "Devices",
"Type" : "Types",
"Name" : "Names",
"Selected" : "{{items}} selected",
"Clear" : "Clear filters",
"NoResultsFound" : "No results found."
},
"Reset": "Reset filters"
},
"Header" : {
"Active": "Active",
"Name": "Name / Description",
"Device": "Device",
"Component": "Component",
"Status": "Status",
"RawValue": "Raw Value",
"FinalValue": "Final Value",
"Actions": "Actions"
},
"Cell" : {
"Waiting" : "Waiting"
},
"Table" : {
"NoResultsFound" : "This is a new configuration. Please add some items."
},
"Actions": {
"OutputConfigItem" : {
"Add": "Add Output Config",
"DefaultName": "New Output Config"
},
"InputConfigItem" : {
"Add": "Add Input Config",
"DefaultName": "New Input Config"
}
}
}
}
44 changes: 44 additions & 0 deletions frontend/public/locales/es/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"ConfigList": {
"Toolbar": {
"Search": {
"Placeholder": "Filtrar elementos..."
},
"Filter": {
"Device": "Dispositivos",
"Type": "Tipos",
"Name": "Nombres",
"Selected": "{{items}} seleccionados",
"Clear": "Borrar filtros",
"NoResultsFound": "No se encontraron resultados."
},
"Reset": "Restablecer filtros"
},
"Header": {
"Active": "Activo",
"Name": "Nombre / Descripción",
"Device": "Dispositivo",
"Component": "Componente",
"Status": "Estado",
"RawValue": "Valor Original",
"FinalValue": "Valor Final",
"Actions": "Acciones"
},
"Cell" : {
"Waiting" : "Esperando"
},
"Table": {
"NoResultsFound": "Nueva configuratión. Por favor, añade algunos elementos."
},
"Actions": {
"OutputConfigItem": {
"Add": "Nueva configuración de Output",
"DefaultName": "Nueva Configuración Output"
},
"InputConfigItem": {
"Add": "Nueva configuración de Input",
"DefaultName": "Nueva Configuración Input"
}
}
}
}
Loading

0 comments on commit 4202cf6

Please sign in to comment.