Skip to content

Commit bcf6caf

Browse files
committed
chore: 🗑️ remove all translations
No language other than English should exist.
1 parent 34e3722 commit bcf6caf

File tree

20 files changed

+24
-1475
lines changed

20 files changed

+24
-1475
lines changed

.github/copilot-instructions.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,13 @@
11
# Contributing to cli-tips
22

3-
Thank you for considering contributing to cli-tips! We welcome contributions from everyone. By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).
3+
Thank you for considering contributing to cli-tips! We welcome contributions from everyone.
44

55
## How to Contribute
66

77
### Reporting Issues
88

99
If you encounter any issues or have suggestions for improvements, please [open an issue on GitHub](https://github.com/cli-stuff/cli-tips/issues/new/choose). Provide as much detail as possible to help us understand and address the problem.
1010

11-
### Adding Translations for Tips
12-
13-
We appreciate your help in adding translations for tips. Follow these steps to add a new translation:
14-
15-
1. **Fork the Repository**: Click the "Fork" button at the top right corner of the repository page to create a copy of the repository in your GitHub account.
16-
17-
2. **Clone the Repository**: Clone the forked repository to your local machine using the following command:
18-
```bash
19-
git clone https://github.com/<your-username>/cli-tips.git
20-
```
21-
22-
3. **Create a New Branch**: Create a new branch for your translation using the following command:
23-
```bash
24-
git checkout -b add-translation-<language-code>
25-
```
26-
27-
4. **Add Translation File**: Navigate to the `translations` directory and add a new file named `<language-code>.txt` (e.g., `es.txt` for Spanish). Add your translations to this file, following the format of existing translation files.
28-
29-
5. **Commit Your Changes**: Commit your changes with a descriptive commit message using the following commands:
30-
```bash
31-
git add translations/<language-code>.txt
32-
git commit -m "Add translations for <language>"
33-
```
34-
35-
6. **Push Your Changes**: Push your changes to your forked repository using the following command:
36-
```bash
37-
git push origin add-translation-<language-code>
38-
```
39-
40-
7. **Create a Pull Request**: Go to the original repository on GitHub and click the "New Pull Request" button. Select your branch and submit the pull request. Provide a clear description of the changes you made.
41-
4211
### Code Style
4312

4413
Please follow these guidelines to maintain a consistent code style:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ debug:
44
@./scripts/debug.sh $(ARGS)
55

66
tests:
7-
@./script/test.sh
7+
@./script/test.sh

README.md

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@
44

55
![CLI Tips Banner](assets/banner.png)
66

7-
<p>
8-
97
`cli-tips` is a command-line tool offering useful Linux tips and commands, which can be integrated as a **Message of the Day** (MOTD).
108

11-
</p>
12-
139
</div>
1410

1511
## ✨ Features
1612

1713
- Displays helpful Linux command tips
18-
- Supports multiple languages
1914
- Easy to install and use
2015

2116
## 📥 Installation
@@ -70,26 +65,6 @@ cli-tips
7065
# Use 'uniq' to remove duplicate lines from a file
7166
```
7267

73-
> [!NOTE]
74-
>
75-
> `cli-tips` automatically detects the user's language and displays tips in that language. You can also set the language manually using the `LANG` environment variable.
76-
77-
### Use Another Language
78-
79-
To display tips in a different language, use the `--lang` option:
80-
81-
```bash
82-
cli-tips --lang=uk
83-
# Output: Використовуйте 'uniq', щоб видалити дубльовані рядки з файлу
84-
```
85-
86-
You can also use the `LANG` environment variable:
87-
88-
```bash
89-
LANG=de cli-tips
90-
# Output: Verwenden Sie 'uniq', um doppelte Zeilen aus einer Datei zu entfernen
91-
```
92-
9368
### Use the `--about` Flag
9469

9570
To display a random tip containing a specific keyword, use the `--about` option:
@@ -101,49 +76,6 @@ cli-tips --about=git
10176

10277
If no tips contain the specified keyword, no tip will be output.
10378

104-
### Available Languages
105-
106-
Here is a list of all available languages:
107-
108-
| Language | Code |
109-
| ----------------------------------- | :--: |
110-
| [🇸🇦 Arabic](translations/ar.txt) | `ar` |
111-
| [🇨🇳 Chinese](translations/cn.txt) | `cn` |
112-
| [🇩🇪 German](translations/de.txt) | `de` |
113-
| [🇬🇧 English](translations/en.txt) | `en` |
114-
| [🇮🇷 Farsi](translations/fa.txt) | `fa` |
115-
| [🇮🇹 Italian](translations/it.txt) | `it` |
116-
| [🇯🇵 Japanese](translations/ja.txt) | `ja` |
117-
| [🇰🇷 Korean](translations/ko.txt) | `ko` |
118-
| [🇵🇱 Polish](translations/pl.txt) | `pl` |
119-
| [🇪🇸 Spanish](translations/es.txt) | `es` |
120-
| [🇺🇦 Ukrainian](translations/uk.txt) | `uk` |
121-
122-
<!-- ### Specify a Custom Folder with Tips Translations
123-
124-
To use a custom folder with tips translations, set the `TIPS_FOLDER` environment variable:
125-
126-
```bash
127-
TIPS_FOLDER=/path/to/tips cli-tips --lang=veryrarelanguage
128-
# Output: <Tip in veryrarelanguage>
129-
```
130-
131-
By default, `cli-tips` uses the built-in tips folder. The custom folder should contain text files in the following format:
132-
133-
```plaintext
134-
tips_<lang_id>.txt
135-
```
136-
137-
Example:
138-
139-
```plaintext
140-
📂 translations/
141-
├── 📄 tips_de.txt
142-
├── 📄 tips_en.txt
143-
├── 📄 tips_pl.txt
144-
└── 📄 tips_uk.txt
145-
``` -->
146-
14779
## 📝 License
14880

14981
This project is fully free and you can do anything you want with it, even without mentioning this repository or license. Enjoy! 🚀
@@ -154,4 +86,4 @@ If you like this project, consider supporting it by starring ⭐ it on GitHub, s
15486

15587
## 🤝 Contributing
15688

157-
We welcome contributions from everyone. If you would like to contribute, please read our [CONTRIBUTING.md](CONTRIBUTING.md) file for detailed instructions on how to add translations and other contributions.
89+
We welcome contributions from everyone. If you would like to contribute, please read our [CONTRIBUTING.md](CONTRIBUTING.md)

cli-tips.sh

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ fi
1818

1919
# Default tips folder
2020
TIPS_FOLDER="${TIPS_FOLDER:-$prefix/share/cli-tips}"
21-
22-
SYSTEM_LANGUAGE="$(echo "$LANG" | cut -d'_' -f1)"
23-
24-
# Default language is based on the user's environment
25-
LANGUAGE="${TIPS_LANGUAGE:-${SYSTEM_LANGUAGE:-en}}"
21+
TIPS_LIST_FILE="$TIPS_FOLDER/tips.txt"
2622

2723
error() {
2824
echo "ERROR: $1" >&2
@@ -34,19 +30,10 @@ show_help() {
3430
echo
3531
echo -e "\e[1mOptions:\e[0m"
3632
echo -e " \e[1;34m-h, --help\e[0m Show this help message and exit"
37-
echo -e " \e[1;34m-l, --lang, --language\e[0m Specify the language for tips"
3833
echo -e " \e[1;34m--about\e[0m Specify a keyword to filter tips"
3934
echo
40-
echo -e "\e[1mAvailable Languages:\e[0m"
41-
printf " "
42-
for file in "$TIPS_FOLDER"/*.txt; do
43-
filename=$(basename "$file" .txt)
44-
echo -en "\e[1;32m$filename\e[0m "
45-
done
4635
echo -e "\n"
4736
echo -e "\e[1mExamples:\e[0m"
48-
echo -e " $(basename "$0") \e[1;34m--language\e[0m en"
49-
echo -e " $(basename "$0") \e[1;34m--language\e[0m es"
5037
echo -e " $(basename "$0") \e[1;34m--about\e[0m git"
5138
echo -e "\n"
5239
echo -e "\e[1mGitHub:\e[0m \e[0;30mhttps://github.com/cli-stuff/cli-tips\e[0m"
@@ -55,16 +42,6 @@ show_help() {
5542
# Parse command-line options
5643
while [[ "$#" -gt 0 ]]; do
5744
case $1 in
58-
-l | --language | --lang)
59-
if [[ -z "$2" ]]; then
60-
error "No language specified"
61-
fi
62-
LANGUAGE="$2"
63-
shift
64-
;;
65-
--language=* | --lang=*)
66-
LANGUAGE="${1#*=}"
67-
;;
6845
--about)
6946
if [[ -z "$2" ]]; then
7047
error "No keyword specified"
@@ -83,22 +60,9 @@ while [[ "$#" -gt 0 ]]; do
8360
shift
8461
done
8562

86-
# Check if the TIPS_FOLDER directory exists
87-
if [ ! -d "$TIPS_FOLDER" ]; then
88-
error "Tips folder '$TIPS_FOLDER' does not exist."
89-
fi
90-
91-
# Find the localized tips file
92-
if [ -f "$TIPS_FOLDER/${LANGUAGE}.txt" ]; then
93-
localized_file="$TIPS_FOLDER/${LANGUAGE}.txt"
94-
else
95-
# echo "Language file '$TIPS_FOLDER/${LANGUAGE}.txt' does not exist. Using default language 'en'."
96-
localized_file="$TIPS_FOLDER/en.txt"
97-
fi
98-
9963
# Read tips from the file into an array
100-
if ! mapfile -t tips <"$localized_file"; then
101-
error "Failed to read tips from file '$localized_file'."
64+
if ! mapfile -t tips <"$TIPS_LIST_FILE"; then
65+
error "Failed to read tips from file '$TIPS_LIST_FILE'."
10266
fi
10367

10468
# Filter tips based on the specified keyword

install.sh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,24 @@ cd "$TEMP_DIR"
4747
# Download the main executable script from GitHub repository
4848
echo "Downloading cli-tips executable..."
4949
curl -sLO "https://raw.githubusercontent.com/$REPO/refs/heads/main/cli-tips.sh" &
50+
pid1=$!
5051

51-
# Create translations directory
52-
mkdir -p translations
52+
echo "Downloading tips list..."
53+
curl -sLO "https://raw.githubusercontent.com/$REPO/refs/heads/main/tips.txt" &
54+
pid2=$!
5355

54-
# Get list of translation files and download them in parallel
55-
echo "Downloading translation files..."
56-
download_urls=$(curl -s "https://api.github.com/repos/$REPO/contents/translations" | grep "download_url" | cut -d '"' -f 4)
56+
wait $pid1
57+
status1=$?
58+
wait $pid2
59+
status2=$?
5760

58-
# Function to download a single translation file
59-
download_translation() {
60-
local url="$1"
61-
local lang=$(echo "$url" | grep -o '[a-z]\+\.txt' | cut -d'_' -f2 | cut -d'.' -f1)
62-
echo "- Downloading $lang translation..."
63-
curl -LOs -C - --output-dir translations "$url"
64-
}
65-
66-
# Start parallel downloads
67-
for url in $download_urls; do
68-
download_translation "$url" &
69-
done
70-
71-
# Wait for all downloads to complete
72-
wait
61+
if [[ $status1 -ne 0 || $status2 -ne 0 ]]; then
62+
echo "Error: Failed to download required files." >&2
63+
rm -rf "$TEMP_DIR"
64+
exit 1
65+
fi
7366

74-
echo ""
67+
echo
7568

7669
echo "Installing..."
7770
# Install the main executable to system bin directory
@@ -80,7 +73,7 @@ $sudo mv cli-tips.sh "$prefix/bin/cli-tips"
8073
chmod +x "$prefix/bin/cli-tips"
8174

8275
$sudo mkdir -p "$prefix/share/cli-tips"
83-
$sudo mv translations/* "$prefix/share/cli-tips"
76+
$sudo mv tips.txt "$prefix/share/cli-tips"
8477

8578
# Clean up temporary installation files
8679
rm -rf "$TEMP_DIR"

scripts/debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
TIPS_FOLDER=translations ./cli-tips.sh "$@"
3+
TIPS_FOLDER=. ./cli-tips.sh "$@"

tests/cli-tips.bats

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ setup() {
55
export TIPS_FOLDER="$(mktemp -d)"
66

77
# Create sample tips files
8-
echo -e "Tip 1 in English\nTip 2 in English" >"$TIPS_FOLDER/en.txt"
9-
echo -e "Consejo 1 en Español\nConsejo 2 en Español" >"$TIPS_FOLDER/es.txt"
8+
echo -e "Tip 1\nTip 2" >"$TIPS_FOLDER/tips.txt"
109

1110
# Path to the script being tested
1211
SCRIPT_PATH="./cli-tips.sh"
@@ -35,63 +34,17 @@ teardown() {
3534
[[ "$output" == *"Unknown option: --unknown"* ]]
3635
}
3736

38-
@test "Prints a tip in default language" {
39-
run "$SCRIPT_PATH"
40-
[ "$status" -eq 0 ]
41-
[[ "$output" == "Tip "* ]]
42-
}
43-
44-
@test "Prints a tip in specified language" {
45-
run "$SCRIPT_PATH" --language es
46-
[ "$status" -eq 0 ]
47-
[[ "$output" == "Consejo "* ]]
48-
}
49-
5037
@test "Filters tips with --about keyword" {
5138
# Add a tip containing the keyword 'git' to the English tips
52-
echo -e "Tip about git" >>"$TIPS_FOLDER/en.txt"
39+
echo -e "Tip about git" >> "$TIPS_FOLDER/tips.txt"
5340

5441
run "$SCRIPT_PATH" --about git
5542
[ "$status" -eq 0 ]
5643
[[ "$output" == "Tip about git" ]]
5744
}
5845

59-
@test "Filters tips with --about keyword and --language option" {
60-
# Add a tip containing the keyword 'git' to the English tips
61-
echo -e "Consejo sobre git" >>"$TIPS_FOLDER/es.txt"
62-
63-
run "$SCRIPT_PATH" --about git --language es
64-
[ "$status" -eq 0 ]
65-
[[ "$output" == "Consejo sobre git" ]]
66-
}
67-
6846
@test "Exits if no matching tips are found" {
6947
run "$SCRIPT_PATH" --about nonexistent
7048
[ "$status" -eq 0 ]
7149
[ -z "$output" ]
7250
}
73-
74-
@test "Uses default language if specified language file is missing" {
75-
rm "$TIPS_FOLDER/es.txt"
76-
run "$SCRIPT_PATH" --language es
77-
[ "$status" -eq 0 ]
78-
[[ "$output" == "Tip "* ]]
79-
}
80-
81-
@test "Errors if no language is specified after --language option" {
82-
run "$SCRIPT_PATH" --language
83-
[ "$status" -ne 0 ]
84-
}
85-
86-
@test "Handles missing TIPS_FOLDER gracefully" {
87-
rm -rf "$TIPS_FOLDER"
88-
run "$SCRIPT_PATH"
89-
[ "$status" -ne 0 ]
90-
}
91-
92-
@test "Handles empty tips file gracefully" {
93-
echo -n "" >"$TIPS_FOLDER/en.txt"
94-
run "$SCRIPT_PATH"
95-
[ "$status" -eq 0 ]
96-
[ -z "$output" ]
97-
}
File renamed without changes.

0 commit comments

Comments
 (0)