feat(i18n): add localization for blacklisted devices & misc additions#73
feat(i18n): add localization for blacklisted devices & misc additions#73Ajit-Mehrotra wants to merge 89 commits intomainfrom
Conversation
* main window in pretty good shape - now onto the popup boxes * hw popup + delegate, os popup + delegate, and dst popup + delegate pretty much in a good spot. based on how the icons are displayed, didn't end up needing orange pngs, because the dark ones can be changed using ColorOverlay * about to start working on options popup * think the settings menu seems okay now * language/keyboard selector & progress bar theming * removal of a few now unused rpi pngs * replace instances of "#2B2A29" with new UnColors singleton member mediumGray * replace instances of "#FF8C2F" with new UnColors singleton member orange * replace instances of "#1C1B1B" with new UnColors singleton member darkGray * replace instances of "#FFFFFF" with color name white
* removes "use saved settings" pop up and always displays options popup instead
* ico for windows * removed rpi-imager.ico and rpi-image.png; mods to CMakeLists.txt to swap from rpi to unraid for windows RC file and copying to 128x128 app icon folder, will need a few other changes to make this work with linux still * renaming application from rpi-imager to unraid-imager * changes for linux * mac icns
* changed os list url in config.h * default select unraid device on load
* seems to be in a good place now for both ident and network config * added in the boot img stuff from the old usb creator (this also ensures that the volume label gets changed to UNRAID) * get rid of unnecessary if inside else clause * works on windows, though i did have to disable secure boot * some misc cleanup: *help button linking to website *info button opening "about" popup *putenv to enable darkmode title bar on windows *remove obe img gz files *minor text edits *changed logo background from white to darkgray * pushing to check on linux and mac
* local commit before switching branches * pushing to check on linux * working on linux * committing new files * completely disable devices in list that have an invalid guid
misc updates: * shrink help/info icons + add text * hyperlink urls in about popup *adjust text in about popup *adjust wording of formatting text *adjust wording of custom img select *limit custom img select to zip files *adjust wording of invalid guid text *add text for missing guid
* renaming unraid-imager -> unraid-usb-creator * more renaming + new icons * guid working on mac, troubleshooting make bootable * rename on format for mac * rather than trying to make the make bootable script work on all platforms (since it's only needed for legacy boot, and we don't let the user select that as an option right now), simply display a message telling the user to run the script after burn successful * fix embedded links in info popup * adding back in linux drive renaming * deb file updates
Co-authored-by: Jessica Reid <jlr@Jessicas-Mini-875.hsd1.va.comcast.net>
Always Run make_bootable.bat on Windows
The legacy url currently being linked to is going away
Fix incorrect link to docs
# Conflicts: # src/imagewriter.cpp # src/linux/org.raspberrypi.rpi-imager.desktop
part 3 up to line 480
* is it this easy? * let's try this again * once more with feeling * let's see if these replace the "2" qml modules from qt5 * try updating control file for debuild * needed for linguist tools? * see if this fixes Qt6::lprodump cmake error * revert previous changes * trying with install-qt-action * syntax error * try specifying something other than latest for os * once more * upload deb artifact * see if we can hack something together here * pick a runner that it can actually find * keep running up that hill * just gonna keep trying some stuff * maybe? * just need to re-trigger the github action * remove changes to mac yml * remove trailing whitespace from yml
- cmake 3.31 (<4.0) - Qt 5 (not Qt6 or latest) - add dmg wrapping for .app for drag and drop installation **Important**: codesigning is still pending automation. Currently dev must: 1. double click the .dmg (drop .app into Applications folder) 2. then finally remove quarantine from .app in Applications folder: `xattr -d com.apple.quarantine /Applications/unraid-usb-creator.app`
- convert GUID validation errors to warnings, allowing users to proceed with Unraid installation even when device GUID is invalid. This supports Unraid 7.2's upcoming internal drive installation via USB. - update gitignore for qt creator and fix build folder typo
… guid validation checks
…cific warnings" This reverts commit 5647a20.
use `#!/usr/bin/env bash` for portability
chore(macos): fix build workflow for macos
feat(gui): allow selecting blacklisted drives & add info tooltip
… for missing localizations (mostly for german)
📝 WalkthroughWalkthroughConsolidates i18n strings into main context and relocates source references to ../main.qml across de/en/es/fr/zh TS files, adding GUID blacklist/device-state texts and marking many legacy contexts/messages as vanished. src/main.qml undergoes formatting and translation-wrapping (qsTr) adjustments without functional logic changes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (8)
src/i18n/unraid-usb-creator_fr.ts (1)
582-585: Wording nit: “Flash Device” vs “périphérique USB”If the UI elsewhere says “clé USB”, consider aligning for consistency: “GUID MANQUANT – Choisissez une autre clé USB”.
src/i18n/unraid-usb-creator_es.ts (1)
603-606: Restore trailing colon and space to match sourceKeep “: ” to match source and UI spacing.
- <source>Help / Feedback: </source> - <translation>Ayuda / Comentarios</translation> + <source>Help / Feedback: </source> + <translation>Ayuda / Comentarios: </translation>src/i18n/unraid-usb-creator_zh.ts (2)
4-18: Unnamed context with only vanished entriesThese can be safely removed to reduce noise; leaving an empty-name context is unusual in TS files.
-<context> - <name></name> - <message> - <source>Play sound when finished</source> - <translation type="vanished">完成时播放声音</translation> - </message> - <message> - <source>Eject media when finished</source> - <translation type="vanished">完成时弹出媒体</translation> - </message> - <message> - <source>SAVE</source> - <translation type="vanished">保存</translation> - </message> -</context>
535-538: Optional wording tweak: “Released: %1”If this is a date, “发布日期:%1” may be clearer than “发行版本:%1”.
src/i18n/unraid-usb-creator_en.ts (1)
190-193: Mark new GUID/blacklist strings as finished (English)For en_US, leaving as “unfinished” falls back to source, which is fine. Still, marking these four new entries as finished avoids ambiguity in tooling.
- <source>GUID: %1</source> - <translation type="unfinished"></translation> + <source>GUID: %1</source> + <translation>GUID: %1</translation> - <source>GUID: %1 <font color='red'>[BLACKLISTED]</font></source> - <translation type="unfinished"></translation> + <source>GUID: %1 <font color='red'>[BLACKLISTED]</font></source> + <translation>GUID: %1 <font color='red'>[BLACKLISTED]</font></translation> - <source><font color='red'>[MISSING GUID - Choose Another Flash Device]</font></source> - <translation type="unfinished"></translation> + <source><font color='red'>[MISSING GUID - Choose Another Flash Device]</font></source> + <translation><font color='red'>[MISSING GUID - Choose Another Flash Device]</font></translation> - <source>This USB device is blacklisted. You may not be able to use this device to get an Unraid license or trial.</source> - <translation type="unfinished"></translation> + <source>This USB device is blacklisted. You may not be able to use this device to get an Unraid license or trial.</source> + <translation>This USB device is blacklisted. You may not be able to use this device to get an Unraid license or trial.</translation>Also applies to: 195-198, 200-203, 205-208
src/main.qml (2)
1359-1381: Well-implemented GUID validation and blacklist UIThe GUID display logic correctly handles three states:
- Valid GUID - displays normally
- Blacklisted GUID - displays with red warning
- Missing GUID - displays error message
All strings are properly internationalized with qsTr().
Consider verifying that the red color (
<font color='red'>) provides sufficient contrast against the dark gray background for accessibility. You might want to use a specific hex color like#ff6b6bfor better visibility.
1044-1044: Complex icon selection logic preservedThe nested ternary operator correctly handles icon selection based on hover state and icon type.
Consider extracting this complex ternary into a helper function for better readability:
function getIconSource(iconUrl, isMouseOver) { if (iconUrl === "https://craftassets.unraid.net/static/favicon/favicon.ico") { return isMouseOver ? "unraid/icons/un-mark-dark-gray.svg" : "unraid/icons/un-mark-gradient.svg"; } else if (iconUrl === "icons/erase.png") { return isMouseOver ? "unraid/icons/erase_dark_gray.svg" : "unraid/icons/erase_orange.svg"; } else if (iconUrl === "icons/use_custom.png") { return isMouseOver ? "unraid/icons/use_custom_dark_gray.svg" : "unraid/icons/use_custom_orange.svg"; } return iconUrl; }src/i18n/unraid-usb-creator_de.ts (1)
384-688: Note: Some existing strings remain untranslatedWhile the new GUID/blacklist strings have been translated, many existing UI strings that were moved to the main context remain untranslated (marked as type="unfinished"). This is acceptable for this PR which focuses on the new functionality, but these should be addressed in a follow-up.
Would you like me to help create a follow-up issue to track the completion of German translations for the remaining UI strings?
| <location filename="../main.qml" line="319"/> | ||
| <location filename="../main.qml" line="1491"/> | ||
| <source>Cancelling...</source> | ||
| <translation>Cancelado...</translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
“Cancelling...” should be progressive, not past tense
Use “Cancelando...” (in-progress), not “Cancelado...” (completed).
- <source>Cancelling...</source>
- <translation>Cancelado...</translation>
+ <source>Cancelling...</source>
+ <translation>Cancelando...</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="319"/> | |
| <location filename="../main.qml" line="1491"/> | |
| <source>Cancelling...</source> | |
| <translation>Cancelado...</translation> | |
| </message> | |
| <location filename="../main.qml" line="319"/> | |
| <location filename="../main.qml" line="1491"/> | |
| <source>Cancelling...</source> | |
| <translation>Cancelando...</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 454 to 458, the Spanish
translation for "Cancelling..." is incorrectly in past tense ("Cancelado...");
replace it with the progressive present "Cancelando..." in that <translation>
element so the UI shows an in-progress cancellation state for both referenced
locations.
| <location filename="../main.qml" line="331"/> | ||
| <source>CANCEL VERIFY</source> | ||
| <translation>Cancelando...</translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Incorrect label for “CANCEL VERIFY”
This is a button label; translate as “CANCELAR VERIFICACIÓN”.
- <source>CANCEL VERIFY</source>
- <translation>Cancelando...</translation>
+ <source>CANCEL VERIFY</source>
+ <translation>CANCELAR VERIFICACIÓN</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="331"/> | |
| <source>CANCEL VERIFY</source> | |
| <translation>Cancelando...</translation> | |
| </message> | |
| <location filename="../main.qml" line="331"/> | |
| <source>CANCEL VERIFY</source> | |
| <translation>CANCELAR VERIFICACIÓN</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 460 to 463, the translation
for the button label "CANCEL VERIFY" is incorrectly given as "Cancelando...";
change it to the imperative phrase "CANCELAR VERIFICACIÓN" (or "CANCELAR
VERIFICACIÓN" in all caps to match UI style) so the label correctly reads as a
cancel action for the verification process.
| <location filename="../main.qml" line="1102"/> | ||
| <source>Online - %1 GB download</source> | ||
| <translation>En línea - %1 GB descarga</translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Improve phrasing for download size
“En línea - %1 GB descarga” is unnatural. Prefer “En línea - descarga de %1 GB”.
- <source>Online - %1 GB download</source>
- <translation>En línea - %1 GB descarga</translation>
+ <source>Online - %1 GB download</source>
+ <translation>En línea - descarga de %1 GB</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1102"/> | |
| <source>Online - %1 GB download</source> | |
| <translation>En línea - %1 GB descarga</translation> | |
| </message> | |
| <location filename="../main.qml" line="1102"/> | |
| <source>Online - %1 GB download</source> | |
| <translation>En línea - descarga de %1 GB</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 547 to 550, update the Spanish
translation for the source "Online - %1 GB download" to use natural phrasing;
replace "En línea - %1 GB descarga" with "En línea - descarga de %1 GB" so the
sentence reads correctly in Spanish.
| <location filename="../main.qml" line="1248"/> | ||
| <source> Mounted as %1</source> | ||
| <translation>Montado como %1</translation> | ||
| </message> |
There was a problem hiding this comment.
💡 Verification agent
❓ Verification inconclusive
Preserve leading space in “ Mounted as %1”
The leading space is significant for in-line concatenation. Mirror it in the translation.
- <source> Mounted as %1</source>
- <translation>Montado como %1</translation>
+ <source> Mounted as %1</source>
+ <translation> Montado como %1</translation>Add leading space to Spanish translation
Lines 557–560 in src/i18n/unraid-usb-creator_es.ts need the same leading space present in the source string for correct inline concatenation.
- <source> Mounted as %1</source>
- <translation>Montado como %1</translation>
+ <source> Mounted as %1</source>
+ <translation> Montado como %1</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1248"/> | |
| <source> Mounted as %1</source> | |
| <translation>Montado como %1</translation> | |
| </message> | |
| <location filename="../main.qml" line="1248"/> | |
| <source> Mounted as %1</source> | |
| <translation> Montado como %1</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 557 to 560, the Spanish
translation for the source string " Mounted as %1" is missing the leading space;
update the translation to include the same leading space before "Montado" so it
matches the source and preserves correct inline concatenation.
💡 Verification agent
🧩 Analysis chain
Automated verification for space and unfinished issues (optional)
Run this to verify leading/trailing spaces and unfinished translations in ES file.
Also applies to: 562-565, 572-575
🏁 Script executed:
#!/bin/bash
set -euo pipefail
f="src/i18n/unraid-usb-creator_es.ts"
echo "Check leading space for ' Mounted as %1'..."
awk '
/<source> Mounted as %1<\/source>/{getline; print; exit}
' "$f" | sed -n 's/^[[:space:]]*<translation>\(.*\)<\/translation>.*/\1/p' | \
grep -q "^ " || { echo "Missing leading space in translation for ' Mounted as %1'"; exit 1; }
echo "Check trailing space for 'Mounted as %1 '..."
awk '
/<source>Mounted as %1 <\/source>/{getline; print; exit}
' "$f" | sed -n 's/^[[:space:]]*<translation>\(.*\)<\/translation>.*/\1/p' | \
grep -q " $" || { echo "Missing trailing space in translation for 'Mounted as %1 '"; exit 1; }
echo "Check unfinished for 'GUID: %1'..."
awk '
/<source>GUID: %1<\/source>/{getline; print; exit}
' "$f" | grep -q 'type="unfinished"' && { echo "GUID: %1 is still unfinished"; exit 1; }
echo "All checks passed."Length of output: 486
Add missing leading space in Spanish translation
The Spanish translation for <source> Mounted as %1</source> in src/i18n/unraid-usb-creator_es.ts is missing its leading space. Please update and apply the same checks to the other occurrences:
• File: src/i18n/unraid-usb-creator_es.ts
– Lines 557–560: change
```diff
- Montado como %1
- Montado como %1
• Also apply to the similar blocks at lines 562–565 and 572–575, ensuring any trailing spaces and that GUID: %1 translations are not marked unfinished.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1248"/> | |
| <source> Mounted as %1</source> | |
| <translation>Montado como %1</translation> | |
| </message> | |
| <location filename="../main.qml" line="1248"/> | |
| <source> Mounted as %1</source> | |
| - <translation>Montado como %1</translation> | |
| + <translation> Montado como %1</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 557–560 (and also inspect the
similar blocks at 562–565 and 572–575), the Spanish translation for "<source>
Mounted as %1</source>" is missing the leading space — update the translation
strings to include the leading space before "Montado" (i.e., " Montado como
%1"), remove any unintended trailing spaces, and ensure the corresponding "GUID:
%1" translations in those blocks are translated and not marked as unfinished;
apply the same fixes to the two other occurrences mentioned.
| <location filename="../main.qml" line="1336"/> | ||
| <source>Mounted as %1 </source> | ||
| <translation>Montado como %1</translation> | ||
| </message> |
There was a problem hiding this comment.
💡 Verification agent
❓ Verification inconclusive
Preserve trailing space in “Mounted as %1 ”
This variant carries a trailing space. Keep it to match UI spacing.
- <source>Mounted as %1 </source>
- <translation>Montado como %1</translation>
+ <source>Mounted as %1 </source>
+ <translation>Montado como %1 </translation>#!/bin/bash
# Show the <location>, <source>, and <translation> for line 1336 across all locale files
rg -A2 '<location filename="../main.qml" line="1336"' -n src/i18n/unraid-usb-creator_*.tsUpdate Spanish translation to preserve trailing space
Please include the trailing space after %1 in the Spanish <translation> to match the source string’s UI spacing.
• File: src/i18n/unraid-usb-creator_es.ts
• Around line 564–565
- <source>Mounted as %1 </source>
- <translation>Montado como %1</translation>
+ <source>Mounted as %1 </source>
+ <translation>Montado como %1 </translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1336"/> | |
| <source>Mounted as %1 </source> | |
| <translation>Montado como %1</translation> | |
| </message> | |
| <location filename="../main.qml" line="1336"/> | |
| <source>Mounted as %1 </source> | |
| <translation>Montado como %1 </translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 562 to 565, the Spanish
translation for the source string "Mounted as %1 " is missing the trailing space
after %1; update the <translation> text so it exactly matches the source spacing
by adding a single space after %1 (i.e., "Montado como %1 ") and save the file
so the UI spacing is preserved.
| <location filename="../main.qml" line="1361"/> | ||
| <source>GUID: %1</source> | ||
| <translation type="unfinished"></translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Finish translation for “GUID: %1”
Avoid “unfinished” to ensure consistent runtime output.
- <source>GUID: %1</source>
- <translation type="unfinished"></translation>
+ <source>GUID: %1</source>
+ <translation>GUID: %1</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation type="unfinished"></translation> | |
| </message> | |
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation>GUID: %1</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 572 to 575, the translation
entry for "GUID: %1" is marked type="unfinished"; replace the empty/unfinished
translation with a finished Spanish string such as "Identificador GUID: %1" (or
"GUID: %1" if you prefer the acronym unchanged) and remove the type="unfinished"
attribute so the runtime shows the completed translation.
| <location filename="../main.qml" line="1406"/> | ||
| <source>About</source> | ||
| <translation>Más información</translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use standard term for “About”
“Más información” is not the usual title for About dialog. Use “Acerca de”.
- <source>About</source>
- <translation>Más información</translation>
+ <source>About</source>
+ <translation>Acerca de</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1406"/> | |
| <source>About</source> | |
| <translation>Más información</translation> | |
| </message> | |
| <location filename="../main.qml" line="1406"/> | |
| <source>About</source> | |
| <translation>Acerca de</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_es.ts around lines 593 to 596, the Spanish
translation for the "About" dialog currently uses "Más información"; change it
to the standard term "Acerca de" by replacing the translation string so the
About dialog uses the conventional Spanish title.
| <location filename="../main.qml" line="1361"/> | ||
| <source>GUID: %1</source> | ||
| <translation type="unfinished"></translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Finish translation for “GUID: %1”
Currently marked unfinished. Provide a localized string to avoid fallback.
- <source>GUID: %1</source>
- <translation type="unfinished"></translation>
+ <source>GUID: %1</source>
+ <translation>GUID : %1</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation type="unfinished"></translation> | |
| </message> | |
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation>GUID : %1</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_fr.ts around lines 572 to 575, the translation
for "GUID: %1" is marked unfinished; replace the empty translation with the
localized French string keeping the placeholder (use "GUID : %1" with a
non-breaking space before the colon) and remove the type="unfinished" attribute
so the file provides a proper French translation and avoids fallback.
| <location filename="../main.qml" line="1361"/> | ||
| <source>GUID: %1</source> | ||
| <translation type="unfinished"></translation> | ||
| </message> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Finish translation for “GUID: %1”
Provide a localized translation.
- <source>GUID: %1</source>
- <translation type="unfinished"></translation>
+ <source>GUID: %1</source>
+ <translation>GUID:%1</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation type="unfinished"></translation> | |
| </message> | |
| <location filename="../main.qml" line="1361"/> | |
| <source>GUID: %1</source> | |
| <translation>GUID:%1</translation> | |
| </message> |
🤖 Prompt for AI Agents
In src/i18n/unraid-usb-creator_zh.ts around lines 575 to 578, the translation
for "GUID: %1" is missing; add a proper Chinese translation that preserves the
placeholder %1 (e.g., "GUID:%1" or a localized equivalent), replacing the empty
translation value so the string and its variable placeholder remain intact.
| function filterItems(list, tags, matchingType) { | ||
| if (!tags || !tags.length) | ||
| return | ||
|
|
||
| var i = list.length | ||
| return; | ||
| var i = list.length; | ||
| while (i--) { | ||
| var entry = list[i] | ||
| var entry = list[i]; | ||
|
|
||
| if ("devices" in entry && entry["devices"].length) { | ||
| var foundTag = false | ||
|
|
||
| switch(matchingType) { | ||
| case 0: /* exact matching */ | ||
| case 2: /* exact matching */ | ||
| for (var j in tags) | ||
| { | ||
| if (entry["devices"].includes(tags[j])) | ||
| { | ||
| foundTag = true | ||
| break | ||
| } | ||
| } | ||
| /* If there's no match, remove this item from the list. */ | ||
| if (!foundTag) | ||
| { | ||
| list.splice(i, 1) | ||
| continue | ||
| var foundTag = false; | ||
|
|
||
| switch (matchingType) { | ||
| case 0: /* exact matching */ | ||
| case 2 /* exact matching */ | ||
| : | ||
| for (var j in tags) { | ||
| if (entry["devices"].includes(tags[j])) { | ||
| foundTag = true; | ||
| break; | ||
| } | ||
| break | ||
| case 1: /* Exlusive by prefix matching */ | ||
| case 3: /* Inclusive by prefix matching */ | ||
| for (var deviceTypePrefix in tags) { | ||
| for (var deviceSpec in entry["devices"]) { | ||
| if (deviceSpec.startsWith(deviceTypePrefix)) { | ||
| foundTag = true | ||
| break | ||
| } | ||
| } | ||
| /* If there's no match, remove this item from the list. */ | ||
| if (!foundTag) { | ||
| list.splice(i, 1); | ||
| continue; | ||
| } | ||
| break; | ||
| case 1: /* Exlusive by prefix matching */ | ||
| case 3 /* Inclusive by prefix matching */ | ||
| : | ||
| for (var deviceTypePrefix in tags) { | ||
| for (var deviceSpec in entry["devices"]) { | ||
| if (deviceSpec.startsWith(deviceTypePrefix)) { | ||
| foundTag = true; | ||
| break; | ||
| } | ||
| /* Terminate outer loop early if we've already | ||
| } | ||
| /* Terminate outer loop early if we've already | ||
| * decided it's a match | ||
| */ | ||
| if (foundTag) { | ||
| break | ||
| } | ||
| } | ||
| /* If there's no match, remove this item from the list. */ | ||
| if (!foundTag) | ||
| { | ||
| list.splice(i, 1) | ||
| continue | ||
| if (foundTag) { | ||
| break; | ||
| } | ||
| break | ||
| } | ||
| /* If there's no match, remove this item from the list. */ | ||
| if (!foundTag) { | ||
| list.splice(i, 1); | ||
| continue; | ||
| } | ||
| break; | ||
| } | ||
| } else { | ||
| /* No device list attached? If we're in an exclusive mode that's bad news indeed. */ | ||
| switch (matchingType) { | ||
| case 0: | ||
| case 1: | ||
| if (!("subitems" in entry)) { | ||
| /* If you're not carrying subitems, you're not going in. */ | ||
| list.splice(i, 1) | ||
| } | ||
| break | ||
| case 2: | ||
| case 3: | ||
| /* Inclusive filtering. We're keeping this one. */ | ||
| break; | ||
| case 0: | ||
| case 1: | ||
| if (!("subitems" in entry)) { | ||
| /* If you're not carrying subitems, you're not going in. */ | ||
| list.splice(i, 1); | ||
| } | ||
| break; | ||
| case 2: | ||
| case 3: | ||
| /* Inclusive filtering. We're keeping this one. */ | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if ("subitems" in entry) { | ||
| filterItems(entry["subitems"], tags, hwTagMatchingType) | ||
| filterItems(entry["subitems"], tags, hwTagMatchingType); | ||
|
|
||
| // If this sub-list has no items then hide it | ||
| if (entry["subitems"].length == 0) { | ||
| list.splice(i, 1) | ||
| list.splice(i, 1); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Complex filtering logic preserved with formatting improvements
The device filtering implementation correctly handles multiple matching types, though the nested switch statements and multiple conditionals make this function quite complex.
There's a potential bug in the nested loops at lines 1650-1651. Both loops use generic names that could cause confusion:
- Line 1650:
for (var deviceTypePrefix in tags) - Line 1651:
for (var deviceSpec in entry["devices"])
The outer loop should use for (var j in tags) to iterate over array indices, not object properties:
- for (var deviceTypePrefix in tags) {
- for (var deviceSpec in entry["devices"]) {
- if (deviceSpec.startsWith(deviceTypePrefix)) {
+ for (var j in tags) {
+ for (var k in entry["devices"]) {
+ if (entry["devices"][k].startsWith(tags[j])) {Consider breaking this function into smaller, more focused functions for each matching type to improve readability and maintainability.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function filterItems(list, tags, matchingType) { | |
| if (!tags || !tags.length) | |
| return | |
| var i = list.length | |
| return; | |
| var i = list.length; | |
| while (i--) { | |
| var entry = list[i] | |
| var entry = list[i]; | |
| if ("devices" in entry && entry["devices"].length) { | |
| var foundTag = false | |
| switch(matchingType) { | |
| case 0: /* exact matching */ | |
| case 2: /* exact matching */ | |
| for (var j in tags) | |
| { | |
| if (entry["devices"].includes(tags[j])) | |
| { | |
| foundTag = true | |
| break | |
| } | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) | |
| { | |
| list.splice(i, 1) | |
| continue | |
| var foundTag = false; | |
| switch (matchingType) { | |
| case 0: /* exact matching */ | |
| case 2 /* exact matching */ | |
| : | |
| for (var j in tags) { | |
| if (entry["devices"].includes(tags[j])) { | |
| foundTag = true; | |
| break; | |
| } | |
| break | |
| case 1: /* Exlusive by prefix matching */ | |
| case 3: /* Inclusive by prefix matching */ | |
| for (var deviceTypePrefix in tags) { | |
| for (var deviceSpec in entry["devices"]) { | |
| if (deviceSpec.startsWith(deviceTypePrefix)) { | |
| foundTag = true | |
| break | |
| } | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) { | |
| list.splice(i, 1); | |
| continue; | |
| } | |
| break; | |
| case 1: /* Exlusive by prefix matching */ | |
| case 3 /* Inclusive by prefix matching */ | |
| : | |
| for (var deviceTypePrefix in tags) { | |
| for (var deviceSpec in entry["devices"]) { | |
| if (deviceSpec.startsWith(deviceTypePrefix)) { | |
| foundTag = true; | |
| break; | |
| } | |
| /* Terminate outer loop early if we've already | |
| } | |
| /* Terminate outer loop early if we've already | |
| * decided it's a match | |
| */ | |
| if (foundTag) { | |
| break | |
| } | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) | |
| { | |
| list.splice(i, 1) | |
| continue | |
| if (foundTag) { | |
| break; | |
| } | |
| break | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) { | |
| list.splice(i, 1); | |
| continue; | |
| } | |
| break; | |
| } | |
| } else { | |
| /* No device list attached? If we're in an exclusive mode that's bad news indeed. */ | |
| switch (matchingType) { | |
| case 0: | |
| case 1: | |
| if (!("subitems" in entry)) { | |
| /* If you're not carrying subitems, you're not going in. */ | |
| list.splice(i, 1) | |
| } | |
| break | |
| case 2: | |
| case 3: | |
| /* Inclusive filtering. We're keeping this one. */ | |
| break; | |
| case 0: | |
| case 1: | |
| if (!("subitems" in entry)) { | |
| /* If you're not carrying subitems, you're not going in. */ | |
| list.splice(i, 1); | |
| } | |
| break; | |
| case 2: | |
| case 3: | |
| /* Inclusive filtering. We're keeping this one. */ | |
| break; | |
| } | |
| } | |
| if ("subitems" in entry) { | |
| filterItems(entry["subitems"], tags, hwTagMatchingType) | |
| filterItems(entry["subitems"], tags, hwTagMatchingType); | |
| // If this sub-list has no items then hide it | |
| if (entry["subitems"].length == 0) { | |
| list.splice(i, 1) | |
| list.splice(i, 1); | |
| } | |
| } | |
| } | |
| } | |
| function filterItems(list, tags, matchingType) { | |
| if (!tags || !tags.length) | |
| return; | |
| var i = list.length; | |
| while (i--) { | |
| var entry = list[i]; | |
| if ("devices" in entry && entry["devices"].length) { | |
| var foundTag = false; | |
| switch (matchingType) { | |
| case 0: /* exact matching */ | |
| case 2 /* exact matching */: | |
| for (var j in tags) { | |
| if (entry["devices"].includes(tags[j])) { | |
| foundTag = true; | |
| break; | |
| } | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) { | |
| list.splice(i, 1); | |
| continue; | |
| } | |
| break; | |
| case 1: /* Exclusive by prefix matching */ | |
| case 3: /* Inclusive by prefix matching */: | |
| for (var j in tags) { | |
| for (var k in entry["devices"]) { | |
| if (entry["devices"][k].startsWith(tags[j])) { | |
| foundTag = true; | |
| break; | |
| } | |
| } | |
| /* Terminate outer loop early if we've already | |
| * decided it's a match | |
| */ | |
| if (foundTag) { | |
| break; | |
| } | |
| } | |
| /* If there's no match, remove this item from the list. */ | |
| if (!foundTag) { | |
| list.splice(i, 1); | |
| continue; | |
| } | |
| break; | |
| } | |
| } else { | |
| /* No device list attached? If we're in an exclusive mode that's bad news indeed. */ | |
| switch (matchingType) { | |
| case 0: | |
| case 1: | |
| if (!("subitems" in entry)) { | |
| /* If you're not carrying subitems, you're not going in. */ | |
| list.splice(i, 1); | |
| } | |
| break; | |
| case 2: | |
| case 3: | |
| /* Inclusive filtering. We're keeping this one. */ | |
| break; | |
| } | |
| } | |
| if ("subitems" in entry) { | |
| filterItems(entry["subitems"], tags, hwTagMatchingType); | |
| // If this sub-list has no items then hide it | |
| if (entry["subitems"].length == 0) { | |
| list.splice(i, 1); | |
| } | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/main.qml around lines 1621-1697, the nested loops at ~1650 use misleading
for-in variable names causing iteration over property names instead of clear
indexes/values; change the outer loop to iterate tags properly (e.g., for (var j
= 0; j < tags.length; j++) or for (var tag of tags)) and the inner loop to
iterate device specs properly (e.g., for (var k = 0; k <
entry["devices"].length; k++) or for (var deviceSpec of entry["devices"])), then
use the chosen loop variables when comparing (tag or tags[j] vs deviceSpec or
entry["devices"][k]); also rename variables to descriptive names (tag,
deviceSpec) to avoid confusion and keep existing break/continue logic intact.
Changes Made:
Main.qml:
qsTr()strings, which marks them for translationTranslation files (.ts):
Added translations for:
All Languages
<source>GUID: %1 <font color='red'>[BLACKLISTED]</font></source><source><font color='red'>[MISSING GUID - Choose Another Flash Device]</font></source><source>This USB device is blacklisted. You may not be able to use this device to get an Unraid license or trial.</source>German Language
<source>Mounted as %1 </source><source>Language: </source><source>Keyboard: </source><source>Info</source><source>Help</source>Summary by CodeRabbit
New Features
Refactor
Style