An open API service indexing awesome lists of open source software.

https://github.com/phillippbertram/go-xc-strings

CLI Tool to cleanup Xcode Localizable.strings
https://github.com/phillippbertram/go-xc-strings

cli go golang localizable-strings swift translation xcode

Last synced: 2 months ago
JSON representation

CLI Tool to cleanup Xcode Localizable.strings

Awesome Lists containing this project

README

          

# xc-strings

`xc-strings` is a command-line tool designed to help Swift developers manage and optimize their localization files.
It provides functionalities to find unused localization keys, clean them from `.strings` files, and optionally sort the keys in these files for better organization.

## Features

- **Find Unused Keys**: Scans Swift files to detect any localization keys that are no longer used.
- **Find Duplicate Keys**: Scans `.strings` files to detect any duplicate keys within the same file.
- **Sort `.strings` Files**: Sorts keys in `.strings` files to maintain a consistent order.

## Installation

### Prerequisites

- Go 1.15 or later

### Building from Source

Clone the repository and build the executable:

```bash
git clone git@github.com:phillippbertram/go-xc-strings.git
cd go-xc-strings

# run directly
go run main.go help

# build and run the executable (macOS)
make build
./dist/go-xc-strings_darwin_arm64/xcs help
```

### Setup Development Environment

- Install [Go](https://golang.org/doc/install)
- Optional: Install golangci-lint: `brew install golangci-lint`
- Optional: Install goreleaser: `brew install goreleaser`

## Usage

```bash
# get help and list all available commands
xcs help

# list unused localization keys
# -b: path to the base localization file
# args: path to the directory containing the Swift files
# --strings: path to the directory containing the .strings files
# -i: optional glob pattern to exclude files (useful to ignore R.string generated files)
xcs unused -b path/to/Localizable.strings -d path/to/swift/files -i "*.generated.swift" App/Resources --remove

# sort strings files
xcs sort App/Resources

# find and remove specific keys from all strings files that are not used in the Swift files
xcs keys "this_is_a_key" "another_key" App/Resources --remove

# find missing translations
xcs missing App/Resources -b App/Resources/en.lproj/Localizable.strings

# open github repository or release page
xcs gh [--releases]
```

## Configuration

No additional configuration is needed to run `xc-strings`.

## Publish New Release (DRAFT)

1. Make sure you are on the `main` branch
2. Make sure the version in `version.go` is correctly set during goreleaser build
3. Create a tag: `git tag -a v0.1.0 -m "Release v0.1.0"` and push it: `git push origin v0.1.0`
4. Run `make release/local` to create a new release
5. Publish Draft [Release](https://github.com/phillippbertram/go-xc-strings/releases)

## Contributing

Contributions are welcome! Please fork the repository and submit pull requests with any enhancements or bug fixes.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

For support, you can open an issue in the GitHub issue tracker.

## Authors

- **Phillipp Bertram** - *Initial work* - [phillippbertram](https://github.com/phillippbertram)