Skip to content

Commit 8638ba9

Browse files
committed
refactor i18n
1 parent 231c08e commit 8638ba9

File tree

3 files changed

+184
-96
lines changed

3 files changed

+184
-96
lines changed

.github/workflows/compile-autoit.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,18 @@ jobs:
3333
$autoItPath = "${env:ProgramFiles(x86)}\AutoIt3\Aut2exe\Aut2exe.exe"
3434
$iconPath = "zoommate.ico"
3535
$buildDir = "build"
36-
3736
# Create build directory if it doesn't exist
3837
if (!(Test-Path $buildDir)) {
3938
New-Item -ItemType Directory -Path $buildDir
4039
}
4140
42-
# Find all translation files and build file parameters
43-
$fileParams = ""
44-
if (Test-Path "i18n") {
45-
$iniFiles = Get-ChildItem -Path "i18n" -Name "*.ini" -Recurse
46-
foreach ($file in $iniFiles) {
47-
$fileParams += " /file ""i18n\$file"""
48-
}
49-
}
50-
5141
# Check if icon file exists
5242
if (Test-Path $iconPath) {
5343
Write-Host "Using icon: $iconPath"
54-
$compileCmd = "& ""$autoItPath"" /in ""ZoomMate.au3"" /out ""$buildDir\ZoomMate.exe"" /icon ""$iconPath""$fileParams"
44+
$compileCmd = "& ""$autoItPath"" /in ""ZoomMate.au3"" /out ""$buildDir\ZoomMate.exe"" /icon ""$iconPath"""
5545
} else {
5646
Write-Host "Icon file not found, compiling without icon"
57-
$compileCmd = "& ""$autoItPath"" /in ""ZoomMate.au3"" /out ""$buildDir\ZoomMate.exe""$fileParams"
47+
$compileCmd = "& ""$autoItPath"" /in ""ZoomMate.au3"" /out ""$buildDir\ZoomMate.exe"""
5848
}
5949
6050
Write-Host "Compilation command: $compileCmd"

Includes/i18n.au3

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
; ================================================================================================
2+
; ZoomMate Translation Data - All Languages
3+
; ================================================================================================
4+
5+
Global Const $TRANSLATIONS = ObjCreate("Scripting.Dictionary")
6+
7+
; Initialize translations for each language
8+
_InitializeTranslations()
9+
10+
Func _InitializeTranslations()
11+
Local $en = ObjCreate("Scripting.Dictionary")
12+
Local $es = ObjCreate("Scripting.Dictionary") ; Spanish placeholder for future use
13+
14+
; Language metadata
15+
$en.Add("LANGNAME", "English")
16+
17+
; Configuration GUI
18+
$en.Add("CONFIG_TITLE", "ZoomMate Configuration")
19+
$en.Add("BTN_SAVE", "Save")
20+
$en.Add("BTN_QUIT", "Quit ZoomMate")
21+
22+
; Status messages
23+
$en.Add("TOOLTIP_IDLE", "Idle")
24+
$en.Add("INFO_ZOOM_LAUNCHING", "Launching Zoom...")
25+
$en.Add("INFO_ZOOM_LAUNCHED", "Zoom meeting launched")
26+
$en.Add("INFO_MEETING_STARTING_IN", "Meeting starting in {0} minute(s).")
27+
$en.Add("INFO_MEETING_STARTED_AGO", "Meeting started {0} minute(s) ago.")
28+
$en.Add("INFO_CONFIG_BEFORE_AFTER_START", "Configuring settings for before and after meetings...")
29+
$en.Add("INFO_CONFIG_BEFORE_AFTER_DONE", "Settings configured for before and after meetings.")
30+
$en.Add("INFO_MEETING_STARTING_SOON_CONFIG", "Meeting starting soon... Configuring settings.")
31+
$en.Add("INFO_CONFIG_DURING_MEETING_DONE", "Settings configured for during the meeting.")
32+
$en.Add("INFO_OUTSIDE_MEETING_WINDOW", "Outside of meeting window. Meeting started more than 2 hours ago.")
33+
$en.Add("INFO_CONFIG_LOADED", "Configuration loaded successfully.")
34+
$en.Add("INFO_NO_MEETING_SCHEDULED", "No meeting scheduled for today. Waiting for the next meeting day...")
35+
36+
; Labels
37+
$en.Add("LABEL_MEETING_ID", "Zoom Meeting ID")
38+
$en.Add("LABEL_MIDWEEK_DAY", "Midweek Day")
39+
$en.Add("LABEL_MIDWEEK_TIME", "Midweek Time (HH:MM)")
40+
$en.Add("LABEL_WEEKEND_DAY", "Weekend Day")
41+
$en.Add("LABEL_WEEKEND_TIME", "Weekend Time (HH:MM)")
42+
43+
; Zoom interface labels
44+
$en.Add("LABEL_HOST_TOOLS", "Host tools")
45+
$en.Add("LABEL_MORE_MEETING_CONTROLS", "More meeting controls")
46+
$en.Add("LABEL_PARTICIPANT", "Participant")
47+
$en.Add("LABEL_MUTE_ALL", "Mute All")
48+
$en.Add("LABEL_YES", "Yes")
49+
$en.Add("LABEL_UNCHECKED_VALUE", "Unchecked")
50+
$en.Add("LABEL_CURRENTLY_UNMUTED_VALUE", "Currently unmuted")
51+
$en.Add("LABEL_UNMUTE_AUDIO_VALUE", "Unmute my audio")
52+
$en.Add("LABEL_STOP_VIDEO_VALUE", "Stop my video")
53+
$en.Add("LABEL_START_VIDEO_VALUE", "Start my video")
54+
$en.Add("LABEL_ZOOM_SECURITY_UNMUTE", "Unmute themselves")
55+
$en.Add("LABEL_ZOOM_SECURITY_SHARE_SCREEN", "Share screen")
56+
57+
; Help text
58+
$en.Add("LABEL_HOST_TOOLS_EXPLAIN", "Enter the text that appears on the Host Tools button in your Zoom interface. This is used to locate and click the button automatically.")
59+
$en.Add("LABEL_PARTICIPANT_EXPLAIN", "Enter the text that appears on the Participants button in your Zoom interface. This is used to locate and open the participants panel.")
60+
$en.Add("LABEL_MUTE_ALL_EXPLAIN", "Enter the text that appears on the Mute All button in your Zoom interface. This is used to mute all participants automatically.")
61+
$en.Add("LABEL_YES_EXPLAIN", "Enter the text that appears on confirmation buttons (e.g., ""Yes"", ""OK"") in your Zoom interface. This is used to confirm actions.")
62+
$en.Add("LABEL_UNCHECKED_VALUE_EXPLAIN", "Enter the text that appears when a setting is unchecked/disabled in your Zoom interface. This is used to detect when settings are disabled.")
63+
$en.Add("LABEL_CURRENTLY_UNMUTED_VALUE_EXPLAIN", "Enter the text that appears on the audio button when you are currently unmuted in your Zoom interface. This is used to detect audio state.")
64+
$en.Add("LABEL_UNMUTE_AUDIO_VALUE_EXPLAIN", "Enter the text that appears on the button to unmute your audio in your Zoom interface. This is used to unmute yourself.")
65+
$en.Add("LABEL_STOP_VIDEO_VALUE_EXPLAIN", "Enter the text that appears on the button to stop your video in your Zoom interface. This is used to stop your video feed.")
66+
$en.Add("LABEL_START_VIDEO_VALUE_EXPLAIN", "Enter the text that appears on the button to start your video in your Zoom interface. This is used to start your video feed.")
67+
$en.Add("LABEL_ZOOM_SECURITY_UNMUTE_EXPLAIN", "Enter the text that appears on the Unmute permission setting in Zoom Security settings. This controls whether participants can unmute themselves.")
68+
$en.Add("LABEL_ZOOM_SECURITY_SHARE_SCREEN_EXPLAIN", "Enter the text that appears on the Share screen permission setting in Zoom Security settings. This controls whether participants can share their screen.")
69+
70+
; Settings
71+
$en.Add("LABEL_SNAP_ZOOM_TO", "Snap Zoom window to")
72+
$en.Add("SNAP_DISABLED", "Disabled")
73+
$en.Add("SNAP_LEFT", "Left")
74+
$en.Add("SNAP_RIGHT", "Right")
75+
$en.Add("LABEL_KEYBOARD_SHORTCUT", "Post-meeting Keyboard Shortcut")
76+
$en.Add("LABEL_KEYBOARD_SHORTCUT_EXPLAIN", "Enter a keyboard shortcut that will apply post-meeting settings (e.g., Ctrl+Alt+Z). Use ^ for Ctrl, ! for Alt, + for Shift, # for Win, followed by a letter or number.")
77+
78+
; Error messages
79+
$en.Add("ERROR_GET_DESKTOP_ELEMENT_FAILED", "Failed to get desktop element.")
80+
$en.Add("ERROR_ZOOM_LAUNCH", "Error launching Zoom")
81+
$en.Add("ERROR_ZOOM_WINDOW_NOT_FOUND", "Zoom window not found")
82+
$en.Add("ERROR_MEETING_ID_NOT_CONFIGURED", "Meeting ID not configured.")
83+
$en.Add("ERROR_MEETING_ID_FORMAT", "Enter 9–11 digits (no spaces)")
84+
$en.Add("ERROR_TIME_FORMAT", "Use 24h time HH:MM")
85+
$en.Add("ERROR_KEYBOARD_SHORTCUT_FORMAT", "Use format like ^!z (Ctrl+Alt+Z). Must include at least one modifier (^ Ctrl, ! Alt, + Shift, # Win) followed by a letter or number.")
86+
$en.Add("ERROR_REQUIRED", "This field is required")
87+
$en.Add("ERROR_FIELDS_REQUIRED", "Please complete all required fields")
88+
$en.Add("ERROR_INVALID_ELEMENT_OBJECT", "Invalid element object.")
89+
$en.Add("ERROR_FAILED_CLICK_ELEMENT", "Failed to click element")
90+
$en.Add("ERROR_SETTING_NOT_FOUND", "Setting not found")
91+
$en.Add("ERROR_UNKNOWN_FEED_TYPE", "Unknown feed type")
92+
93+
; Overlay messages
94+
$en.Add("PLEASE_WAIT_TITLE", "Please Wait")
95+
$en.Add("PLEASE_WAIT_TEXT", "Please wait...")
96+
$en.Add("POST_MEETING_HIT_KEY_TITLE", "Post-Meeting Settings")
97+
$en.Add("POST_MEETING_HIT_KEY_TEXT", "Are you ready to apply post-meeting settings? Press ENTER when the prayer is over to apply them, or ESC to cancel.")
98+
99+
; Section headers
100+
$en.Add("SECTION_MEETING_INFO", "Meeting Information")
101+
$en.Add("SECTION_ZOOM_LABELS", "Zoom Interface Labels")
102+
$en.Add("SECTION_GENERAL_SETTINGS", "General Settings")
103+
104+
; Day labels (1=Sunday .. 7=Saturday)
105+
$en.Add("DAY_1", "Sunday")
106+
$en.Add("DAY_2", "Monday")
107+
$en.Add("DAY_3", "Tuesday")
108+
$en.Add("DAY_4", "Wednesday")
109+
$en.Add("DAY_5", "Thursday")
110+
$en.Add("DAY_6", "Friday")
111+
$en.Add("DAY_7", "Saturday")
112+
113+
; Spanish translations (placeholder for future implementation)
114+
$es.Add("LANGNAME", "Español")
115+
$es.Add("CONFIG_TITLE", "Configuración de ZoomMate")
116+
$es.Add("BTN_SAVE", "Guardar")
117+
$es.Add("BTN_QUIT", "Salir de ZoomMate")
118+
; Add more Spanish translations as needed...
119+
120+
; Add language dictionaries to main translations object
121+
$TRANSLATIONS.Add("en", $en)
122+
$TRANSLATIONS.Add("es", $es)
123+
EndFunc ;==>_InitializeTranslations
124+
125+
; Helper function to get translations for a specific language
126+
; @param $langCode - Language code (e.g., "en", "es")
127+
; @return Object - Dictionary containing translations for the specified language
128+
Func _GetLanguageTranslations($langCode)
129+
If $TRANSLATIONS.Exists($langCode) Then
130+
Return $TRANSLATIONS.Item($langCode)
131+
Else
132+
; Fallback to English if requested language not found
133+
Return $TRANSLATIONS.Item("en")
134+
EndIf
135+
EndFunc ;==>_GetLanguageTranslations
136+
137+
; Builds a comma-separated list of available language display names
138+
; @return String - Comma-separated list of language names
139+
Func _ListAvailableLanguageNames()
140+
Local $list = ""
141+
For $langCode In $TRANSLATIONS.Keys
142+
Local $translations = _GetLanguageTranslations($langCode)
143+
If $translations.Exists("LANGNAME") Then
144+
Local $langName = $translations.Item("LANGNAME")
145+
$list &= ($list = "" ? $langName : "," & $langName)
146+
EndIf
147+
Next
148+
Return $list
149+
EndFunc ;==>_ListAvailableLanguageNames
150+
151+
; Gets the display name for a language code
152+
; @param $code - Language code (e.g., "en", "es")
153+
; @return String - Display name or the code itself if not found
154+
Func _GetLanguageDisplayName($code)
155+
Local $translations = _GetLanguageTranslations($code)
156+
If $translations.Exists("LANGNAME") Then
157+
Return $translations.Item("LANGNAME")
158+
EndIf
159+
Return $code
160+
EndFunc ;==>_GetLanguageDisplayName

ZoomMate.au3

Lines changed: 22 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
; COMPILER DIRECTIVES AND INCLUDES
1010
; ================================================================================================
1111
#AutoIt3Wrapper_UseX64=y
12+
#AutoIt3Wrapper_Res_File_Add=images\host_tools.jpg, rt_rcdata, host_tools_jpg
13+
#AutoIt3Wrapper_Res_File_Add=images\more_meeting_controls.jpg, rt_rcdata, more_meeting_controls_jpg
14+
#AutoIt3Wrapper_Res_File_Add=images\participant.jpg, rt_rcdata, participant_jpg
15+
#AutoIt3Wrapper_Res_File_Add=images\mute_all.jpg, rt_rcdata, mute_all_jpg
16+
#AutoIt3Wrapper_Res_File_Add=images\yes.jpg, rt_rcdata, yes_jpg
17+
#AutoIt3Wrapper_Res_File_Add=images\security_unmute.jpg, rt_rcdata, security_unmute_jpg
18+
#AutoIt3Wrapper_Res_File_Add=images\security_share_screen.jpg, rt_rcdata, security_share_screen_jpg
19+
#AutoIt3Wrapper_Res_File_Add=images\placeholder.jpg, rt_rcdata, placeholder_jpg
1220
#include <MsgBoxConstants.au3>
1321
#include <Array.au3>
1422
#include <FileConstants.au3>
@@ -23,6 +31,7 @@
2331
#include <EditConstants.au3>
2432
#include "Includes\UIA_Functions-a.au3"
2533
#include "Includes\CUIAutomation2.au3"
34+
#include "Includes\i18n.au3"
2635

2736
; ================================================================================================
2837
; AUTOIT OPTIONS AND CONSTANTS
@@ -130,97 +139,27 @@ EndFunc ;==>_UTF8ToString
130139
; @param $p0-$p2 - Optional placeholder values for {0}, {1}, {2} substitution
131140
; @return String - Translated text with placeholders replaced
132141
Func t($key, $p0 = Default, $p1 = Default, $p2 = Default)
133-
; Try current language first
134-
If $g_Languages.Exists($g_CurrentLang) Then
135-
Local $oDict = $g_Languages.Item($g_CurrentLang)
136-
If $oDict.Exists($key) Then
137-
Local $s = $oDict.Item($key)
138-
; Replace placeholders if provided
139-
If $p0 <> Default Then $s = StringReplace($s, "{0}", $p0, 0, $STR_CASESENSE)
140-
If $p1 <> Default Then $s = StringReplace($s, "{1}", $p1, 0, $STR_CASESENSE)
141-
If $p2 <> Default Then $s = StringReplace($s, "{2}", $p2, 0, $STR_CASESENSE)
142-
Return $s
143-
EndIf
144-
EndIf
142+
; Get the configured language from settings (fallback to English if not set)
143+
Local $currentLang = GetUserSetting("Language")
144+
If $currentLang = "" Then $currentLang = "en"
145145

146-
; Fallback to English if current language doesn't have the key
147-
If $g_Languages.Exists("en") Then
148-
Local $oEn = $g_Languages.Item("en")
149-
If $oEn.Exists($key) Then
150-
Local $s2 = $oEn.Item($key)
151-
If $p0 <> Default Then $s2 = StringReplace($s2, "{0}", $p0, 0, $STR_CASESENSE)
152-
If $p1 <> Default Then $s2 = StringReplace($s2, "{1}", $p1, 0, $STR_CASESENSE)
153-
If $p2 <> Default Then $s2 = StringReplace($s2, "{2}", $p2, 0, $STR_CASESENSE)
154-
Return $s2
155-
EndIf
146+
; Get translations for the current language
147+
Local $translations = _GetLanguageTranslations($currentLang)
148+
149+
If $translations.Exists($key) Then
150+
Local $s = $translations.Item($key)
151+
; Replace placeholders if provided
152+
If $p0 <> Default Then $s = StringReplace($s, "{0}", $p0, 0, $STR_CASESENSE)
153+
If $p1 <> Default Then $s = StringReplace($s, "{1}", $p1, 0, $STR_CASESENSE)
154+
If $p2 <> Default Then $s = StringReplace($s, "{2}", $p2, 0, $STR_CASESENSE)
155+
Return $s
156156
EndIf
157157

158158
; Ultimate fallback: return the key itself
159159
Return $key
160160
EndFunc ;==>t
161161

162-
; Loads all translation files from the i18n directory
163-
; Scans for *.ini files and builds language dictionaries
164-
Func _LoadTranslations()
165-
Local $sDir = @ScriptDir & "\i18n\*.ini"
166-
Local $hSearch = FileFindFirstFile($sDir)
167-
If $hSearch = -1 Then Return ; No translation files found
168-
169-
While 1
170-
Local $sFile = FileFindNextFile($hSearch)
171-
If @error Then ExitLoop
172-
173-
; Extract language code from filename (remove .ini extension)
174-
Local $lang = StringTrimRight($sFile, 4)
175-
Local $fullPath = @ScriptDir & "\i18n\" & $sFile
176-
177-
; Read all translations from the [translations] section
178-
Local $a = IniReadSection($fullPath, "translations")
179-
If @error Then ContinueLoop
180-
181-
; Build translation dictionary for this language
182-
Local $dict = ObjCreate("Scripting.Dictionary")
183-
For $i = 1 To $a[0][0]
184-
; Apply UTF-8 to Unicode conversion for translation values
185-
Local $sKey = $a[$i][0]
186-
Local $sValue = _StringToUTF8($a[$i][1])
187-
$dict.Add($sKey, $sValue)
188-
Next
189-
190-
; Store language dictionary
191-
If $g_Languages.Exists($lang) Then $g_Languages.Remove($lang)
192-
$g_Languages.Add($lang, $dict)
193-
194-
; Build language name mappings for GUI dropdown
195-
Local $langName = ""
196-
If $dict.Exists("LANGNAME") Then $langName = $dict.Item("LANGNAME")
197-
If $langName = "" Then $langName = $lang ; Use code as fallback
198-
199-
If $g_LangCodeToName.Exists($lang) Then $g_LangCodeToName.Remove($lang)
200-
$g_LangCodeToName.Add($lang, $langName)
201-
If $g_LangNameToCode.Exists($langName) Then $g_LangNameToCode.Remove($langName)
202-
$g_LangNameToCode.Add($langName, $lang)
203-
WEnd
204-
FileClose($hSearch)
205-
EndFunc ;==>_LoadTranslations
206-
207-
; Builds a comma-separated list of available language display names
208-
; @return String - Comma-separated list of language names
209-
Func _ListAvailableLanguageNames()
210-
Local $list = ""
211-
For $name In $g_LangNameToCode.Keys
212-
$list &= ($list = "" ? $name : "," & $name)
213-
Next
214-
Return $list
215-
EndFunc ;==>_ListAvailableLanguageNames
216162

217-
; Gets the display name for a language code
218-
; @param $code - Language code (e.g., "en", "es")
219-
; @return String - Display name or the code itself if not found
220-
Func _GetLanguageDisplayName($code)
221-
If $g_LangCodeToName.Exists($code) Then Return $g_LangCodeToName.Item($code)
222-
Return $code
223-
EndFunc ;==>_GetLanguageDisplayName
224163

225164
; Initializes day name to number mappings using translations
226165
; Maps localized day names (DAY_1 through DAY_7) to numbers 1-7
@@ -2384,7 +2323,6 @@ Func CheckMeetingWindow($meetingTime)
23842323
EndFunc ;==>CheckMeetingWindow
23852324

23862325
; Load translations and configuration
2387-
_LoadTranslations()
23882326
LoadMeetingConfig()
23892327
_InitDayLabelMaps()
23902328

0 commit comments

Comments
 (0)