Skip to content

Instantly share code, notes, and snippets.

@Laicure
Last active July 23, 2025 18:20
Show Gist options
  • Save Laicure/701d119afe37345998a7a3dfb60b3b8a to your computer and use it in GitHub Desktop.
Save Laicure/701d119afe37345998a7a3dfb60b3b8a to your computer and use it in GitHub Desktop.
removes non-english (retains base) localizations on MacOS. Used for Apple Script and export as Application.
on run
-- 0) Count how many non‑English .lproj folders there are
set countCmd to "find /Applications -type d -name '*.lproj' " & ¬
"! -iname 'en.lproj' ! -iname 'Base.lproj' -print | wc -l"
set countBefore to do shell script countCmd -- this is already text
if countBefore is "0" then
display notification "No non‑English .lproj folders found; nothing to delete." with title "Cleanup Complete"
return
end if
-- 1) Cleanup: delete them with sudo
set cleanupCmd to "find /Applications -type d -name '*.lproj' " & ¬
"! -iname 'en.lproj' ! -iname 'Base.lproj' " & ¬
"-print0 | while IFS= read -r -d '' DIR; do " & ¬
"P=\"$DIR\"; " & ¬
"while [[ \"$P\" != \"/\" && ! ( \"$P\" == *.app || \"$P\" == *.framework || \"$P\" == *.bundle ) ]]; do " & ¬
"P=${P%/*}; done; " & ¬
"NAME=$(basename \"$P\" .app); " & ¬
"NAME=$(basename \"$NAME\" .framework); " & ¬
"NAME=$(basename \"$NAME\" .bundle); " & ¬
"LANG=$(basename \"$DIR\" .lproj); " & ¬
"echo \"Deleting $NAME $LANG\"; rm -rf \"$DIR\"; " & ¬
"done"
do shell script cleanupCmd with administrator privileges
-- 2) Notify how many were deleted
display notification (countBefore & " non‑English .lproj folders deleted.") with title "Cleanup Complete"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment