Skip to content

Instantly share code, notes, and snippets.

@Laicure
Last active August 31, 2025 14:45
Show Gist options
  • Select an option

  • Save Laicure/701d119afe37345998a7a3dfb60b3b8a to your computer and use it in GitHub Desktop.

Select an option

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
-- Count non-English .lproj folders (exclude any en* variants, English, and Base)
set countCmd to "find /Applications -type d -name '*.lproj' " & ¬
"! -iname 'en*.lproj' ! -iname 'english.lproj' ! -iname 'base.lproj' -print | wc -l"
set countBefore to do shell script countCmd -- text
if countBefore is "0" then
display notification "No non-English .lproj folders found; nothing to delete." with title "Cleanup Complete"
return
end if
-- Cleanup: delete them with admin privileges, echoing deletions (output not visible in the .app UI)
set cleanupCmd to "find /Applications -type d -name '*.lproj' " & ¬
"! -iname 'en*.lproj' ! -iname 'english.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
-- 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