Skip to content

remove unused localizable keys in a specific case (when you use an enum as a layer to access your localizable files)

Notifications You must be signed in to change notification settings

AbdulrahmanQasem95/removeUnusedLocalizableKeys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

This script is designed to work in a specific case when you have an enum to access localizble files as a buffer layer

for example:

in ConstantTexts.swift

enum ConstantTexts: String {
    case mainScreenTitle = "main_screen_title"
}

in Base.lproj/Localizable.strings

"main_screen_title" = "Your app title";

in ar.lproj/Localizable.strings

"main_screen_title" = "عنوان التطبيق";

and so on for other languages

Description

  • Determines unused localization keys by scanning Swift files in the project.
  • Optionally removes unused keys from the specified language file.
  • Creates a backup of the original language file before removal.

Prerequisites

  • Swift installed on your machine.

Running the Script

  1. add strings-sweeper.swift anywhere
  2. open terminal
  3. change directory to the folder where you add strings-sweeper.swift
    (cd path/to/strings-sweeper.swift)
  4. run the following command after replacing paths with your paths:
    swift strings-sweeper.swift --langEnum **/path/to/localization/enum/ConstantTexts.swift** --lang **/path/to/localization/folder/Localization** --remove

Replace /path/to/localization/enum/ConstantTexts.swift with the actual path to your enumKyes.strings file.
Replace /path/to/localization/folder/Localization with the actual path to your localizable folder.

The --remove flag is optional and will automatically remove unused keys from the file.

for example:

swift strings-sweeper.swift --langEnum /Users/abdulrahmanqasem/Desktop/Abdulrahman/baaz_ios_new/Baaz/Baaz/Helpers/ConstantTexts.swift --lang /Users/abdulrahmanqasem/Desktop/Abdulrahman/baaz_ios_new/Baaz/BaaziOS/Resources/Localization --remove

inspired by: Strings Sweeper

سخ

About

remove unused localizable keys in a specific case (when you use an enum as a layer to access your localizable files)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages