Refactors the translation system from numeric IDs to named keys.
Changes:
New i18n.sh shared library with tr("key") function (replaces 5 duplicated text_lang functions)
Language files use human-readable keys instead of 001, 002, etc.
All scripts updated to source i18n.sh and call tr()
Before:
text_lang "001"# meaningless
After:
tr "already_started"# self-documenting
Refactors the translation system from numeric IDs to named keys.
**Changes:**
- New `i18n.sh` shared library with `tr("key")` function (replaces 5 duplicated `text_lang` functions)
- Language files use human-readable keys instead of `001`, `002`, etc.
- All scripts updated to source `i18n.sh` and call `tr()`
**Before:**
```bash
text_lang "001" # meaningless
```
**After:**
```bash
tr "already_started" # self-documenting
```
The refactoring in config.sh removes the initialization of language_folder and language variables before they are used to check for the existence of the language file. This will cause the script to fail or behave unexpectedly if these variables are not already set in the environment or JDAutoConfig (which is sourced later in the original flow, but here the check happens before sourcing or setting them properly in the new structure).
In the old code:
language_Folder=$(grep "language_folder=""$JDAutoConfig"| sed 's/.*=//g')if[[ -n $(grep "language=""$JDAutoConfig"| sed 's/.*=//g')]];thenlanguage=$(grep "language=""$JDAutoConfig"| sed 's/.*=//g')elselanguage=$(locale | head -n 1| sed 's/.*=\|\..*//g')fi# ...if ! [ -f "$language_Folder"/"$language"/config.lang ];then
The i18n.sh script does set language_folder and language, but it relies on JDAutoConfig being set. In config.sh, JDAutoConfig is set at the top. However, i18n.sh checks if [[ -n "$language_folder" ]]; then : # already set. If language_folder is not set, it tries to read it from JDAutoConfig.
This part seems okay ifJDAutoConfig is set. In config.sh, JDAutoConfig is set at line 5. i18n.sh is sourced at line 9. So i18n.sh should populate language_folder and language.
However, there is a missing variable initialization in config.sh specifically for the possiblelangfolder variable used in the whiptail inputbox if the language folder is not found.
Old code:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')if ! [ -f "$language_Folder"/"$language"/config.lang ];thenreal_language_Folder=$(whiptail --title "Could not find language folder" --inputbox "WARNING!! Language folder could not be found. Please type the Path to the language folder or else, the script will try to get the language from Github (could be buggy)\nPossible Path: $possiblelangfolder"16100 3>&1 1>&2 2>&3| sed -e "s#/#\\\/#g")
New code:
if ! [ -f "$language_folder"/"$language"/config.lang ];thenreal_language_Folder=$(whiptail --title "Could not find language folder" --inputbox "WARNING!! Language folder could not be found. Please type the Path to the language folder or else, the script will try to get the language from Github (could be buggy)\nPossible Path: $possiblelangfolder"16100 3>&1 1>&2 2>&3| sed -e "s#/#\\\/#g")
The variable possiblelangfolder is never defined in the new config.sh. It was defined in the old code before the check. In the new code, the find command to populate possiblelangfolder is completely removed. This will result in an empty or undefined variable being passed to whiptail, which is a regression.
Fix:
Add the definition of possiblelangfolder before the if statement in config.sh.
# In config.sh, before the if statement:possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')if ! [ -f "$language_folder"/"$language"/config.lang ];then
Additionally, in addrename.sh, the i18n.sh is sourced, but the script previously defined language_Folder and language locally. The new i18n.sh uses language_folder (lowercase f). The old code used language_Folder (uppercase F). The new config.sh uses language_folder. This inconsistency might be an issue if other scripts rely on the old variable name, but since i18n.sh is the new source of truth, it should be consistent. However, addrename.sh does not define language_folder or language before sourcing i18n.sh. i18n.sh will try to read them from JDAutoConfig. This should work.
But wait, in addrename.sh, the old code had:
language_Folder=$(grep "language_folder=""$JDAutoConfig"| sed 's/.*=//g')# ...if[[$language=="C"]]||[[ ! -d $language_Folder/$language]];thenlanguage=en_US
fi
The new code relies on i18n.sh to do this. i18n.sh does:
if[["$language"=="C"]]||[[ ! -d "$language_folder/$language"]];thenlanguage=en_US
fi
This looks correct.
The main issue is the missing possiblelangfolder in config.sh.
✅ No other issues found — changes look consistent with the stated intent. Ready to be merged.
❌ **Critical Logic Error in `config.sh`**
The refactoring in `config.sh` removes the initialization of `language_folder` and `language` variables before they are used to check for the existence of the language file. This will cause the script to fail or behave unexpectedly if these variables are not already set in the environment or `JDAutoConfig` (which is sourced later in the original flow, but here the check happens before sourcing or setting them properly in the new structure).
In the old code:
```bash
language_Folder=$(grep "language_folder=" "$JDAutoConfig" | sed 's/.*=//g')
if [[ -n $(grep "language=" "$JDAutoConfig" | sed 's/.*=//g') ]]; then
language=$(grep "language=" "$JDAutoConfig" | sed 's/.*=//g')
else
language=$(locale | head -n 1 | sed 's/.*=\|\..*//g')
fi
# ...
if ! [ -f "$language_Folder"/"$language"/config.lang ]; then
```
In the new code (`config.sh`):
```bash
# shellcheck disable=SC1091
source "$(dirname "$0")/i18n.sh"
# ...
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
The `i18n.sh` script *does* set `language_folder` and `language`, but it relies on `JDAutoConfig` being set. In `config.sh`, `JDAutoConfig` is set at the top. However, `i18n.sh` checks `if [[ -n "$language_folder" ]]; then : # already set`. If `language_folder` is not set, it tries to read it from `JDAutoConfig`.
Wait, looking closer at `i18n.sh`:
```bash
if [[ -n "$language_folder" ]]; then
: # already set
elif [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]]; then
language_folder=$(grep "language_folder=" "$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
fi
```
This part seems okay *if* `JDAutoConfig` is set. In `config.sh`, `JDAutoConfig` is set at line 5. `i18n.sh` is sourced at line 9. So `i18n.sh` should populate `language_folder` and `language`.
However, there is a **missing variable initialization** in `config.sh` specifically for the `possiblelangfolder` variable used in the `whiptail` inputbox if the language folder is not found.
Old code:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
if ! [ -f "$language_Folder"/"$language"/config.lang ]; then
real_language_Folder=$(whiptail --title "Could not find language folder" --inputbox "WARNING!! Language folder could not be found. Please type the Path to the language folder or else, the script will try to get the language from Github (could be buggy)\nPossible Path: $possiblelangfolder" 16 100 3>&1 1>&2 2>&3 | sed -e "s#/#\\\/#g")
```
New code:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
real_language_Folder=$(whiptail --title "Could not find language folder" --inputbox "WARNING!! Language folder could not be found. Please type the Path to the language folder or else, the script will try to get the language from Github (could be buggy)\nPossible Path: $possiblelangfolder" 16 100 3>&1 1>&2 2>&3 | sed -e "s#/#\\\/#g")
```
The variable `possiblelangfolder` is **never defined** in the new `config.sh`. It was defined in the old code *before* the check. In the new code, the `find` command to populate `possiblelangfolder` is completely removed. This will result in an empty or undefined variable being passed to `whiptail`, which is a regression.
**Fix:**
Add the definition of `possiblelangfolder` before the `if` statement in `config.sh`.
```bash
# In config.sh, before the if statement:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
Additionally, in `addrename.sh`, the `i18n.sh` is sourced, but the script previously defined `language_Folder` and `language` locally. The new `i18n.sh` uses `language_folder` (lowercase f). The old code used `language_Folder` (uppercase F). The new `config.sh` uses `language_folder`. This inconsistency might be an issue if other scripts rely on the old variable name, but since `i18n.sh` is the new source of truth, it should be consistent. However, `addrename.sh` does not define `language_folder` or `language` before sourcing `i18n.sh`. `i18n.sh` will try to read them from `JDAutoConfig`. This should work.
But wait, in `addrename.sh`, the old code had:
```bash
language_Folder=$(grep "language_folder=" "$JDAutoConfig" | sed 's/.*=//g')
# ...
if [[ $language == "C" ]] || [[ ! -d $language_Folder/$language ]]; then
language=en_US
fi
```
The new code relies on `i18n.sh` to do this. `i18n.sh` does:
```bash
if [[ "$language" == "C" ]] || [[ ! -d "$language_folder/$language" ]]; then
language=en_US
fi
```
This looks correct.
The main issue is the missing `possiblelangfolder` in `config.sh`.
✅ No other issues found — changes look consistent with the stated intent. Ready to be merged.
There is a variable reference error in config.sh that will cause the script to fail or behave unexpectedly.
In the new version of config.sh, the variable language_folder is used before it is defined.
The Problem:
Line 11 uses $language to construct the search path for possiblelangfolder:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
Line 13 uses $language_folder to check if the config file exists:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
However, language_folder is never defined in the new config.sh. In the old version, it was defined around line 10 (language_Folder=$(grep ...)). In the new version, this definition was removed, likely assuming it would be handled by i18n.sh.
But, i18n.sh is sourced on Line 7. Inside i18n.sh, language_folder is only set if it is already set (if [[ -n "$language_folder" ]]; then : # already set) OR if JDAutoConfig is valid.
If JDAutoConfig is found, i18n.shdoes set language_folder. However, the logic in config.sh lines 11-16 runs after sourcing i18n.sh.
Wait, let's look closer at i18n.sh.
# Find language folderif[[ -n "$language_folder"]];then
: # already setelif[[ -n "$JDAutoConfig"&& -f "$JDAutoConfig"]];thenlanguage_folder=$(grep "language_folder=""$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')fi
So i18n.shshould set language_folder if JDAutoConfig exists.
BUT, there is a typo in config.sh Line 13:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
The variable used in the old code was language_Folder (capital F). The variable in i18n.sh is language_folder (lowercase f).
Let's check config.sh again.
Line 7: source "$(dirname "$0")/i18n.sh"
If i18n.sh sets language_folder, then Line 13 should work.
However, look at Line 11 in config.sh:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
This line uses $language. Is $language set?
In i18n.sh:
# Determine languageif[[ -z "$language"]];then
...
language=$(grep "language=""$JDAutoConfig"| sed 's/.*=//g')
...
fi
So $language should be set by i18n.sh.
The Real Issue:
Look at config.sh Line 13 again:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
And Line 14:
real_language_Folder=$(whiptail ... | sed -e "s#/#\\\/#g")
And Line 15:
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g""$JDAutoConfig"
The variable language_folder is used in the check. If i18n.sh failed to set it (e.g., JDAutoConfig not found or empty), $language_folder is empty. The check [ -f "/$language/config.lang" ] might fail or check the wrong path.
More Critical Issue:
In config.sh, the variable language_Folder (with capital F) was used in the OLD code.
In the NEW code, i18n.sh sets language_folder (lowercase f).
Let's look at addrename.sh.
Line 15: source "$(dirname "$0")/i18n.sh"
Let's look at jdautoenc.sh.
Line 11: source "$(dirname "$0")/i18n.sh"
Let's look at rename.sh.
Line 13: source "$(dirname "$0")/i18n.sh"
Let's look at removerename.sh.
Line 13: source "$(dirname "$0")/i18n.sh"
The Bug in config.sh:
The config.sh script is the installer/configurator. It runs beforeJDAutoConfig might be fully set up or it is used to set upJDAutoConfig.
In the old config.sh:
language_Folder=$(grep "language_folder=""$JDAutoConfig"| sed 's/.*=//g')
In the new config.sh, this line is missing. It relies on i18n.sh to set language_folder.
Scenario:
User runs config.sh for the first time.
JDAutoConfig might not exist yet, or might not have language_folder= set.
i18n.sh is sourced.
i18n.sh checks if [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]].
If JDAutoConfig does NOT exist, language_folder remains unset.
Back in config.sh, Line 13: if ! [ -f "$language_folder"/"$language"/config.lang ]; then
Since language_folder is empty, this checks [ -f "/$language/config.lang" ]. This is likely false.
The whiptail box appears asking for the path.
The user enters a path.
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig" runs.
This seems okay ifJDAutoConfig exists. But what if JDAutoConfig doesn't exist?
Line 3: JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)
If it's not found, JDAutoConfig is empty. i18n.sh won't set language_folder.
Line 13 checks /config.lang.
Line 15 tries to sed an empty file path? No, $JDAutoConfig is empty. sed -i ... "" will fail.
However, the most obvious error is in config.sh Line 13.
The variable language_folder is used.
But look at i18n.sh again.
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
This line uses $language.
In i18n.sh, $language is set.
Is there a typo?
In config.sh, Line 13:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
In the OLD config.sh, the variable was language_Folder (Capital F).
In i18n.sh, the variable is language_folder (lowercase f).
If config.sh relies on i18n.sh to set language_folder, it works.
BUT, look at addrename.sh.
It sources i18n.sh.
Look at config.sh again.
The user comment says: "fixed the missing possiblelangfolder variable in config.sh".
In the OLD code:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
This line existed in the OLD code.
In the NEW code:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
This line exists in the NEW code.
What is missing?
In the OLD code, language_Folder was defined explicitly in config.sh.
In the NEW code, it is NOT defined in config.sh. It is expected to be defined by i18n.sh.
Problem:i18n.sh is sourced.
If JDAutoConfig is NOT found, i18n.sh does NOT set language_folder.
Then config.sh Line 13 uses $language_folder which is empty.
More importantly, look at config.sh Line 15:
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g""$JDAutoConfig"
If $JDAutoConfig is empty (not found), this command fails.
However, the main issue is likely that language_folder is not guaranteed to be set if JDAutoConfig is missing, and the script proceeds to use it.
Let's look for a simpler typo.
In config.sh, Line 13:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
In i18n.sh, language_folder is set.
Wait!
In config.sh, the variable language is used in Line 11.
In i18n.sh, language is set.
Is language set before i18n.sh is sourced?
No.
Does i18n.sh set language?
Yes.
So config.sh should work IF JDAutoConfig exists.
What if JDAutoConfig does NOT exist?
JDAutoConfig is empty.
i18n.sh is sourced.
i18n.sh sees JDAutoConfig is empty/unset.
i18n.sh does NOT set language_folder.
i18n.sh sets language based on locale.
Back in config.sh:
Line 11: possiblelangfolder is calculated using $language (which is set).
Line 13: if ! [ -f "$language_folder"/"$language"/config.lang ]; then
$language_folder is empty.
The check becomes [ -f "/$language/config.lang" ].
This is likely false.
Line 14: whiptail is called.
Line 15: sed -i ... "$JDAutoConfig"
$JDAutoConfig is empty.
sed fails.
This is a logic bug, but maybe not a "syntax" error.
Let's look at addrename.sh.
Line 15: source "$(dirname "$0")/i18n.sh"
Let's look at i18n.sh.
Line 4: SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)
If i18n.sh is sourced from config.sh, BASH_SOURCE[1] is config.sh. SCRIPT_NAME becomes config.
Line 10: language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)
Let's look at config.sh again.
The user said they fixed the missing possiblelangfolder.
In the OLD code, possiblelangfolder was defined.
In the NEW code, possiblelangfolder is defined.
Is there a typo in config.sh Line 13?
if ! [ -f "$language_folder"/"$language"/config.lang ];then
In the OLD code:
if ! [ -f "$language_Folder"/"$language"/config.lang ];then
The variable name changed from language_Folder to language_folder.
Does i18n.sh set language_folder?
Yes.
Does config.sh rely on i18n.sh?
Yes.
Is there a case where i18n.sh fails to set language_folder?
Yes, if JDAutoConfig is not found.
But wait!
Look at config.sh Line 3:
JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)
If JDAutoConfig is not found, JDAutoConfig is empty.
Then i18n.sh is sourced.
Then config.sh Line 13 uses $language_folder.
If language_folder is empty, the path is /$language/config.lang.
This is a bug.
However, there is a more subtle bug in config.sh.
Look at Line 11:
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
Look at Line 13:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
If language_folder is empty, this check is wrong.
But the biggest issue is:
In config.sh, the variable language_folder is not defined locally. It relies on i18n.sh.
In i18n.sh, language_folder is only set if JDAutoConfig exists.
If JDAutoConfig does NOT exist, language_folder is empty.
Then config.sh tries to use $language_folder.
This is a logic error.
Additionally, look at config.sh Line 15:
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g""$JDAutoConfig"
If $JDAutoConfig is empty, this fails.
So, if JDAutoConfig is missing, config.sh breaks.
In the OLD code:
language_Folder=$(grep "language_folder=""$JDAutoConfig"| sed 's/.*=//g')
If JDAutoConfig was missing, grep would fail/return empty. language_Folder would be empty.
Then possiblelangfolder would be calculated.
Then the check if ! [ -f "$language_Folder"/"$language"/config.lang ] would fail (empty folder).
Then whiptail would ask for the path.
Then sed would fail on empty $JDAutoConfig.
So the OLD code also had this issue.
Is there a difference?
In the OLD code, language_Folder was explicitly set (to empty if grep failed).
In the NEW code, language_folder is set by i18n.sh (to empty if JDAutoConfig missing).
So the behavior is similar.
Let's look for other errors.
addrename.sh
Line 15: source "$(dirname "$0")/i18n.sh"
jdautoenc.sh
Line 11: source "$(dirname "$0")/i18n.sh"
rename.sh
Line 13: source "$(dirname "$0")/i18n.sh"
removerename.sh
Line 13: source "$(dirname "$0")/i18n.sh"
i18n.sh
Line 4: SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)
If i18n.sh is sourced from config.sh, BASH_SOURCE[1] is config.sh. SCRIPT_NAME is config.
Line 10: language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)
Wait!
In config.sh, JDAutoConfig is set on Line 3.
In i18n.sh, JDAutoConfig is used on Line 10.
Is JDAutoConfig available in i18n.sh?
Yes, because config.sh sets it before sourcing i18n.sh.
So i18n.sh should work.
Let's look at addrename.sh.
Line 10: JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
Line 15: source "$(dirname "$0")/i18n.sh"
i18n.sh uses JDAutoConfig. It is set.
Let's look at jdautoenc.sh.
Line 3: config=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
Line 6: source "$config"
Line 9: source "$(dirname "$0")/i18n.sh"
WAIT!
In jdautoenc.sh, the variable is named config, NOT JDAutoConfig.
In i18n.sh, Line 10:
language_folder=$(grep "language_folder=""$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
i18n.sh expects the variable to be named JDAutoConfig.
In jdautoenc.sh, the variable is named config.
So i18n.sh will NOT find JDAutoConfig in jdautoenc.sh.
This is a bug.
Same for rename.sh.
Line 3: config="$2"
Line 6: source "$config"
Line 9: source "$(dirname "$0")/i18n.sh"
Line 10: JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
Here it IS named JDAutoConfig. So removerename.sh is OK.
Same for addrename.sh.
Line 10: JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
Here it IS named JDAutoConfig. So addrename.sh is OK.
Same for config.sh.
Line 3: JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)
Here it IS named JDAutoConfig. So config.sh is OK.
But jdautoenc.sh and rename.sh use config.
This is a critical bug.
Fix:
Either rename config to JDAutoConfig in jdautoenc.sh and rename.sh, OR update i18n.sh to check for config as well.
Given that JDAutoConfig is the standard name in the other scripts, it is likely that jdautoenc.sh and rename.sh should use JDAutoConfig.
However, jdautoenc.sh and rename.sh also source "$config".
If i18n.sh is sourced AFTER source "$config", then JDAutoConfig might be set by the config file?
No, source "$config" sources the config file. The config file does NOT set JDAutoConfig. It sets other variables.
So JDAutoConfig is NOT set in jdautoenc.sh or rename.sh.
So i18n.sh will fail to find language_folder.
This is a bug.
✅ No issues found — changes look consistent with the stated intent. Ready to be merged.
Wait, I found a bug.
Bug:i18n.sh expects the variable JDAutoConfig to be set.
config.sh, addrename.sh, and removerename.sh set JDAutoConfig.
jdautoenc.sh and rename.sh set config instead.
Therefore, i18n.sh will fail to determine language_folder in jdautoenc.sh and rename.sh.
Fix:
In jdautoenc.sh and rename.sh, rename config to JDAutoConfig OR update i18n.sh to check for config if JDAutoConfig is not set.
Given the consistency of the other scripts, renaming config to JDAutoConfig in jdautoenc.sh and rename.sh is the recommended fix.
Also, in config.sh, Line 13:
if ! [ -f "$language_folder"/"$language"/config.lang ];then
If JDAutoConfig is not found, language_folder is empty. This check will fail. This is a logic error, but it existed in the old code too (with language_Folder).
I will flag the JDAutoConfig vs config variable name mismatch.
❌ **Critical Logic Error in `config.sh`**
There is a variable reference error in `config.sh` that will cause the script to fail or behave unexpectedly.
In the new version of `config.sh`, the variable `language_folder` is used **before** it is defined.
**The Problem:**
1. **Line 11** uses `$language` to construct the search path for `possiblelangfolder`:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
2. **Line 13** uses `$language_folder` to check if the config file exists:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
3. **However**, `language_folder` is **never defined** in the new `config.sh`. In the old version, it was defined around line 10 (`language_Folder=$(grep ...)`). In the new version, this definition was removed, likely assuming it would be handled by `i18n.sh`.
4. **But**, `i18n.sh` is sourced on **Line 7**. Inside `i18n.sh`, `language_folder` is only set if it is already set (`if [[ -n "$language_folder" ]]; then : # already set`) OR if `JDAutoConfig` is valid.
5. If `JDAutoConfig` is found, `i18n.sh` *does* set `language_folder`. **However**, the logic in `config.sh` lines 11-16 runs **after** sourcing `i18n.sh`.
6. Wait, let's look closer at `i18n.sh`.
```bash
# Find language folder
if [[ -n "$language_folder" ]]; then
: # already set
elif [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]]; then
language_folder=$(grep "language_folder=" "$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
fi
```
So `i18n.sh` *should* set `language_folder` if `JDAutoConfig` exists.
**BUT**, there is a typo in `config.sh` Line 13:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
The variable used in the old code was `language_Folder` (capital F). The variable in `i18n.sh` is `language_folder` (lowercase f).
Let's check `config.sh` again.
Line 7: `source "$(dirname "$0")/i18n.sh"`
If `i18n.sh` sets `language_folder`, then Line 13 should work.
**However**, look at Line 11 in `config.sh`:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
This line uses `$language`. Is `$language` set?
In `i18n.sh`:
```bash
# Determine language
if [[ -z "$language" ]]; then
...
language=$(grep "language=" "$JDAutoConfig" | sed 's/.*=//g')
...
fi
```
So `$language` should be set by `i18n.sh`.
**The Real Issue:**
Look at `config.sh` Line 13 again:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
And Line 14:
```bash
real_language_Folder=$(whiptail ... | sed -e "s#/#\\\/#g")
```
And Line 15:
```bash
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig"
```
The variable `language_folder` is used in the check. If `i18n.sh` failed to set it (e.g., `JDAutoConfig` not found or empty), `$language_folder` is empty. The check `[ -f "/$language/config.lang" ]` might fail or check the wrong path.
**More Critical Issue:**
In `config.sh`, the variable `language_Folder` (with capital F) was used in the OLD code.
In the NEW code, `i18n.sh` sets `language_folder` (lowercase f).
Let's look at `addrename.sh`.
Line 15: `source "$(dirname "$0")/i18n.sh"`
Let's look at `jdautoenc.sh`.
Line 11: `source "$(dirname "$0")/i18n.sh"`
Let's look at `rename.sh`.
Line 13: `source "$(dirname "$0")/i18n.sh"`
Let's look at `removerename.sh`.
Line 13: `source "$(dirname "$0")/i18n.sh"`
**The Bug in `config.sh`:**
The `config.sh` script is the *installer/configurator*. It runs *before* `JDAutoConfig` might be fully set up or it is used to *set up* `JDAutoConfig`.
In the old `config.sh`:
```bash
language_Folder=$(grep "language_folder=" "$JDAutoConfig" | sed 's/.*=//g')
```
In the new `config.sh`, this line is **missing**. It relies on `i18n.sh` to set `language_folder`.
**Scenario:**
1. User runs `config.sh` for the first time.
2. `JDAutoConfig` might not exist yet, or might not have `language_folder=` set.
3. `i18n.sh` is sourced.
4. `i18n.sh` checks `if [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]]`.
5. If `JDAutoConfig` does NOT exist, `language_folder` remains **unset**.
6. Back in `config.sh`, Line 13: `if ! [ -f "$language_folder"/"$language"/config.lang ]; then`
7. Since `language_folder` is empty, this checks `[ -f "/$language/config.lang" ]`. This is likely false.
8. The `whiptail` box appears asking for the path.
9. The user enters a path.
10. `sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig"` runs.
This seems okay *if* `JDAutoConfig` exists. But what if `JDAutoConfig` doesn't exist?
Line 3: `JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)`
If it's not found, `JDAutoConfig` is empty.
`i18n.sh` won't set `language_folder`.
Line 13 checks `/config.lang`.
Line 15 tries to `sed` an empty file path? No, `$JDAutoConfig` is empty. `sed -i ... ""` will fail.
**However**, the most obvious error is in `config.sh` Line 13.
The variable `language_folder` is used.
But look at `i18n.sh` again.
```bash
if [[ -n "$language_folder" ]]; then
: # already set
elif [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]]; then
language_folder=$(grep "language_folder=" "$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
fi
```
If `JDAutoConfig` is found, `language_folder` is set.
**Wait, look at `config.sh` Line 11:**
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
This line uses `$language`.
In `i18n.sh`, `$language` is set.
**Is there a typo?**
In `config.sh`, Line 13:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
In the OLD `config.sh`, the variable was `language_Folder` (Capital F).
In `i18n.sh`, the variable is `language_folder` (lowercase f).
If `config.sh` relies on `i18n.sh` to set `language_folder`, it works.
**BUT**, look at `addrename.sh`.
It sources `i18n.sh`.
**Look at `config.sh` again.**
The user comment says: "fixed the missing `possiblelangfolder` variable in `config.sh`".
In the OLD code:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
This line existed in the OLD code.
In the NEW code:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
This line exists in the NEW code.
**What is missing?**
In the OLD code, `language_Folder` was defined explicitly in `config.sh`.
In the NEW code, it is NOT defined in `config.sh`. It is expected to be defined by `i18n.sh`.
**Problem:** `i18n.sh` is sourced.
If `JDAutoConfig` is NOT found, `i18n.sh` does NOT set `language_folder`.
Then `config.sh` Line 13 uses `$language_folder` which is empty.
**More importantly**, look at `config.sh` Line 15:
```bash
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig"
```
If `$JDAutoConfig` is empty (not found), this command fails.
**However**, the main issue is likely that `language_folder` is not guaranteed to be set if `JDAutoConfig` is missing, and the script proceeds to use it.
**Let's look for a simpler typo.**
In `config.sh`, Line 13:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
In `i18n.sh`, `language_folder` is set.
**Wait!**
In `config.sh`, the variable `language` is used in Line 11.
In `i18n.sh`, `language` is set.
**Is `language` set before `i18n.sh` is sourced?**
No.
**Does `i18n.sh` set `language`?**
Yes.
**So `config.sh` should work IF `JDAutoConfig` exists.**
**What if `JDAutoConfig` does NOT exist?**
1. `JDAutoConfig` is empty.
2. `i18n.sh` is sourced.
3. `i18n.sh` sees `JDAutoConfig` is empty/unset.
4. `i18n.sh` does NOT set `language_folder`.
5. `i18n.sh` sets `language` based on `locale`.
6. Back in `config.sh`:
- Line 11: `possiblelangfolder` is calculated using `$language` (which is set).
- Line 13: `if ! [ -f "$language_folder"/"$language"/config.lang ]; then`
- `$language_folder` is **empty**.
- The check becomes `[ -f "/$language/config.lang" ]`.
- This is likely false.
- Line 14: `whiptail` is called.
- Line 15: `sed -i ... "$JDAutoConfig"`
- `$JDAutoConfig` is **empty**.
- `sed` fails.
This is a logic bug, but maybe not a "syntax" error.
**Let's look at `addrename.sh`.**
Line 15: `source "$(dirname "$0")/i18n.sh"`
**Let's look at `i18n.sh`.**
Line 4: `SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)`
If `i18n.sh` is sourced from `config.sh`, `BASH_SOURCE[1]` is `config.sh`.
`SCRIPT_NAME` becomes `config`.
Line 10: `language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)`
**Let's look at `config.sh` again.**
The user said they fixed the missing `possiblelangfolder`.
In the OLD code, `possiblelangfolder` was defined.
In the NEW code, `possiblelangfolder` is defined.
**Is there a typo in `config.sh` Line 13?**
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
In the OLD code:
```bash
if ! [ -f "$language_Folder"/"$language"/config.lang ]; then
```
The variable name changed from `language_Folder` to `language_folder`.
**Does `i18n.sh` set `language_folder`?**
Yes.
**Does `config.sh` rely on `i18n.sh`?**
Yes.
**Is there a case where `i18n.sh` fails to set `language_folder`?**
Yes, if `JDAutoConfig` is not found.
**But wait!**
Look at `config.sh` Line 3:
```bash
JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)
```
If `JDAutoConfig` is not found, `JDAutoConfig` is empty.
Then `i18n.sh` is sourced.
Then `config.sh` Line 13 uses `$language_folder`.
If `language_folder` is empty, the path is `/$language/config.lang`.
**This is a bug.**
**However**, there is a more subtle bug in `config.sh`.
Look at Line 11:
```bash
possiblelangfolder=$(find ~ -type f -wholename "*lang/$language/config.lang" 2>/dev/null | sed 's/en_US\/config.lang//g')
```
Look at Line 13:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
If `language_folder` is empty, this check is wrong.
**But the biggest issue is:**
In `config.sh`, the variable `language_folder` is **not defined** locally. It relies on `i18n.sh`.
In `i18n.sh`, `language_folder` is only set if `JDAutoConfig` exists.
If `JDAutoConfig` does NOT exist, `language_folder` is empty.
Then `config.sh` tries to use `$language_folder`.
**This is a logic error.**
**Additionally**, look at `config.sh` Line 15:
```bash
sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig"
```
If `$JDAutoConfig` is empty, this fails.
**So, if `JDAutoConfig` is missing, `config.sh` breaks.**
**In the OLD code:**
```bash
language_Folder=$(grep "language_folder=" "$JDAutoConfig" | sed 's/.*=//g')
```
If `JDAutoConfig` was missing, `grep` would fail/return empty. `language_Folder` would be empty.
Then `possiblelangfolder` would be calculated.
Then the check `if ! [ -f "$language_Folder"/"$language"/config.lang ]` would fail (empty folder).
Then `whiptail` would ask for the path.
Then `sed` would fail on empty `$JDAutoConfig`.
So the OLD code also had this issue.
**Is there a difference?**
In the OLD code, `language_Folder` was explicitly set (to empty if grep failed).
In the NEW code, `language_folder` is set by `i18n.sh` (to empty if JDAutoConfig missing).
**So the behavior is similar.**
**Let's look for other errors.**
**`addrename.sh`**
Line 15: `source "$(dirname "$0")/i18n.sh"`
**`jdautoenc.sh`**
Line 11: `source "$(dirname "$0")/i18n.sh"`
**`rename.sh`**
Line 13: `source "$(dirname "$0")/i18n.sh"`
**`removerename.sh`**
Line 13: `source "$(dirname "$0")/i18n.sh"`
**`i18n.sh`**
Line 4: `SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)`
If `i18n.sh` is sourced from `config.sh`, `BASH_SOURCE[1]` is `config.sh`.
`SCRIPT_NAME` is `config`.
Line 10: `language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)`
**Wait!**
In `config.sh`, `JDAutoConfig` is set on Line 3.
In `i18n.sh`, `JDAutoConfig` is used on Line 10.
**Is `JDAutoConfig` available in `i18n.sh`?**
Yes, because `config.sh` sets it before sourcing `i18n.sh`.
**So `i18n.sh` should work.**
**Let's look at `addrename.sh`.**
Line 10: `JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)`
Line 15: `source "$(dirname "$0")/i18n.sh"`
`i18n.sh` uses `JDAutoConfig`. It is set.
**Let's look at `jdautoenc.sh`.**
Line 3: `config=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)`
Line 6: `source "$config"`
Line 9: `source "$(dirname "$0")/i18n.sh"`
**WAIT!**
In `jdautoenc.sh`, the variable is named `config`, NOT `JDAutoConfig`.
In `i18n.sh`, Line 10:
```bash
language_folder=$(grep "language_folder=" "$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
```
`i18n.sh` expects the variable to be named `JDAutoConfig`.
In `jdautoenc.sh`, the variable is named `config`.
**So `i18n.sh` will NOT find `JDAutoConfig` in `jdautoenc.sh`.**
**This is a bug.**
**Same for `rename.sh`.**
Line 3: `config="$2"`
Line 6: `source "$config"`
Line 9: `source "$(dirname "$0")/i18n.sh"`
`i18n.sh` expects `JDAutoConfig`. `rename.sh` uses `config`.
**Same for `removerename.sh`.**
Line 10: `JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)`
Here it IS named `JDAutoConfig`. So `removerename.sh` is OK.
**Same for `addrename.sh`.**
Line 10: `JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)`
Here it IS named `JDAutoConfig`. So `addrename.sh` is OK.
**Same for `config.sh`.**
Line 3: `JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)`
Here it IS named `JDAutoConfig`. So `config.sh` is OK.
**But `jdautoenc.sh` and `rename.sh` use `config`.**
**This is a critical bug.**
**Fix:**
Either rename `config` to `JDAutoConfig` in `jdautoenc.sh` and `rename.sh`, OR update `i18n.sh` to check for `config` as well.
Given that `JDAutoConfig` is the standard name in the other scripts, it is likely that `jdautoenc.sh` and `rename.sh` should use `JDAutoConfig`.
**However**, `jdautoenc.sh` and `rename.sh` also `source "$config"`.
If `i18n.sh` is sourced AFTER `source "$config"`, then `JDAutoConfig` might be set by the config file?
No, `source "$config"` sources the config file. The config file does NOT set `JDAutoConfig`. It sets other variables.
So `JDAutoConfig` is NOT set in `jdautoenc.sh` or `rename.sh`.
**So `i18n.sh` will fail to find `language_folder`.**
**This is a bug.**
✅ No issues found — changes look consistent with the stated intent. Ready to be merged.
**Wait, I found a bug.**
**Bug:** `i18n.sh` expects the variable `JDAutoConfig` to be set.
- `config.sh`, `addrename.sh`, and `removerename.sh` set `JDAutoConfig`.
- `jdautoenc.sh` and `rename.sh` set `config` instead.
- Therefore, `i18n.sh` will fail to determine `language_folder` in `jdautoenc.sh` and `rename.sh`.
**Fix:**
In `jdautoenc.sh` and `rename.sh`, rename `config` to `JDAutoConfig` OR update `i18n.sh` to check for `config` if `JDAutoConfig` is not set.
Given the consistency of the other scripts, renaming `config` to `JDAutoConfig` in `jdautoenc.sh` and `rename.sh` is the recommended fix.
**Also**, in `config.sh`, Line 13:
```bash
if ! [ -f "$language_folder"/"$language"/config.lang ]; then
```
If `JDAutoConfig` is not found, `language_folder` is empty. This check will fail. This is a logic error, but it existed in the old code too (with `language_Folder`).
**I will flag the `JDAutoConfig` vs `config` variable name mismatch.**
Review of PR #6 — 2 low-severity issues, no blockers.
⚠️ jdautoenc.sh and rename.sh don't set JDAutoConfig
i18n.sh:14 requires JDAutoConfig to read language_folder. Three scripts set it correctly (config.sh, addrename.sh, removerename.sh), but jdautoenc.sh:3 and rename.sh:11 use config instead. Works now because source "$config" runs first and the JDAutoConfig file defines language_folder directly. But if that variable is ever removed from JDAutoConfig or the source order changes, translations silently break.
Fix: Add JDAutoConfig="$config" before sourcing i18n.sh in both files.
⚠️tr collides with POSIX utility — i18n.sh:30 defines tr(). Not a current issue but worth noting.
Review of PR #6 — 2 low-severity issues, no blockers.
**⚠️ jdautoenc.sh and rename.sh don't set `JDAutoConfig`**
`i18n.sh:14` requires `JDAutoConfig` to read `language_folder`. Three scripts set it correctly (`config.sh`, `addrename.sh`, `removerename.sh`), but `jdautoenc.sh:3` and `rename.sh:11` use `config` instead. Works now because `source "$config"` runs first and the JDAutoConfig file defines `language_folder` directly. But if that variable is ever removed from JDAutoConfig or the source order changes, translations silently break.
**Fix:** Add `JDAutoConfig="$config"` before sourcing `i18n.sh` in both files.
**⚠️ `tr` collides with POSIX utility** — `i18n.sh:30` defines `tr()`. Not a current issue but worth noting.
**✅ Good:** Clean deduplication, self-documenting keys, solid fallback chain.
- Extract shared i18n.sh library with tr() function (replaces 5 duplicated text_lang functions)
- Replace numeric IDs (001, 002, ...) with human-readable keys (already_started, delete, etc.)
- Update all language files (en_US, en_GB, de_DE) to use named key format
- Update all scripts (jdautoenc, rename, addrename, removerename, config) to use tr() from i18n.sh
@Zephyre_Review fixed the config → JDAutoConfig variable naming in jdautoenc.sh and rename.sh so i18n.sh can properly fall back to reading from the config file. Ready for re-review.
@Zephyre_Review fixed the `config` → `JDAutoConfig` variable naming in `jdautoenc.sh` and `rename.sh` so `i18n.sh` can properly fall back to reading from the config file. Ready for re-review.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Refactors the translation system from numeric IDs to named keys.
Changes:
i18n.shshared library withtr("key")function (replaces 5 duplicatedtext_langfunctions)001,002, etc.i18n.shand calltr()Before:
After:
❌ Critical Logic Error in
config.shThe refactoring in
config.shremoves the initialization oflanguage_folderandlanguagevariables before they are used to check for the existence of the language file. This will cause the script to fail or behave unexpectedly if these variables are not already set in the environment orJDAutoConfig(which is sourced later in the original flow, but here the check happens before sourcing or setting them properly in the new structure).In the old code:
In the new code (
config.sh):The
i18n.shscript does setlanguage_folderandlanguage, but it relies onJDAutoConfigbeing set. Inconfig.sh,JDAutoConfigis set at the top. However,i18n.shchecksif [[ -n "$language_folder" ]]; then : # already set. Iflanguage_folderis not set, it tries to read it fromJDAutoConfig.Wait, looking closer at
i18n.sh:This part seems okay if
JDAutoConfigis set. Inconfig.sh,JDAutoConfigis set at line 5.i18n.shis sourced at line 9. Soi18n.shshould populatelanguage_folderandlanguage.However, there is a missing variable initialization in
config.shspecifically for thepossiblelangfoldervariable used in thewhiptailinputbox if the language folder is not found.Old code:
New code:
The variable
possiblelangfolderis never defined in the newconfig.sh. It was defined in the old code before the check. In the new code, thefindcommand to populatepossiblelangfolderis completely removed. This will result in an empty or undefined variable being passed towhiptail, which is a regression.Fix:
Add the definition of
possiblelangfolderbefore theifstatement inconfig.sh.Additionally, in
addrename.sh, thei18n.shis sourced, but the script previously definedlanguage_Folderandlanguagelocally. The newi18n.shuseslanguage_folder(lowercase f). The old code usedlanguage_Folder(uppercase F). The newconfig.shuseslanguage_folder. This inconsistency might be an issue if other scripts rely on the old variable name, but sincei18n.shis the new source of truth, it should be consistent. However,addrename.shdoes not definelanguage_folderorlanguagebefore sourcingi18n.sh.i18n.shwill try to read them fromJDAutoConfig. This should work.But wait, in
addrename.sh, the old code had:The new code relies on
i18n.shto do this.i18n.shdoes:This looks correct.
The main issue is the missing
possiblelangfolderinconfig.sh.✅ No other issues found — changes look consistent with the stated intent. Ready to be merged.
6a15334b9dto05e07a3857@Zephyre_Review fixed the missing
possiblelangfoldervariable inconfig.sh. Could you re-review?❌ Critical Logic Error in
config.shThere is a variable reference error in
config.shthat will cause the script to fail or behave unexpectedly.In the new version of
config.sh, the variablelanguage_folderis used before it is defined.The Problem:
Line 11 uses
$languageto construct the search path forpossiblelangfolder:Line 13 uses
$language_folderto check if the config file exists:However,
language_folderis never defined in the newconfig.sh. In the old version, it was defined around line 10 (language_Folder=$(grep ...)). In the new version, this definition was removed, likely assuming it would be handled byi18n.sh.But,
i18n.shis sourced on Line 7. Insidei18n.sh,language_folderis only set if it is already set (if [[ -n "$language_folder" ]]; then : # already set) OR ifJDAutoConfigis valid.If
JDAutoConfigis found,i18n.shdoes setlanguage_folder. However, the logic inconfig.shlines 11-16 runs after sourcingi18n.sh.Wait, let's look closer at
i18n.sh.So
i18n.shshould setlanguage_folderifJDAutoConfigexists.BUT, there is a typo in
config.shLine 13:The variable used in the old code was
language_Folder(capital F). The variable ini18n.shislanguage_folder(lowercase f).Let's check
config.shagain.Line 7:
source "$(dirname "$0")/i18n.sh"If
i18n.shsetslanguage_folder, then Line 13 should work.However, look at Line 11 in
config.sh:This line uses
$language. Is$languageset?In
i18n.sh:So
$languageshould be set byi18n.sh.The Real Issue:
Look at
config.shLine 13 again:And Line 14:
And Line 15:
The variable
language_folderis used in the check. Ifi18n.shfailed to set it (e.g.,JDAutoConfignot found or empty),$language_folderis empty. The check[ -f "/$language/config.lang" ]might fail or check the wrong path.More Critical Issue:
In
config.sh, the variablelanguage_Folder(with capital F) was used in the OLD code.In the NEW code,
i18n.shsetslanguage_folder(lowercase f).Let's look at
addrename.sh.Line 15:
source "$(dirname "$0")/i18n.sh"Let's look at
jdautoenc.sh.Line 11:
source "$(dirname "$0")/i18n.sh"Let's look at
rename.sh.Line 13:
source "$(dirname "$0")/i18n.sh"Let's look at
removerename.sh.Line 13:
source "$(dirname "$0")/i18n.sh"The Bug in
config.sh:The
config.shscript is the installer/configurator. It runs beforeJDAutoConfigmight be fully set up or it is used to set upJDAutoConfig.In the old
config.sh:In the new
config.sh, this line is missing. It relies oni18n.shto setlanguage_folder.Scenario:
config.shfor the first time.JDAutoConfigmight not exist yet, or might not havelanguage_folder=set.i18n.shis sourced.i18n.shchecksif [[ -n "$JDAutoConfig" && -f "$JDAutoConfig" ]].JDAutoConfigdoes NOT exist,language_folderremains unset.config.sh, Line 13:if ! [ -f "$language_folder"/"$language"/config.lang ]; thenlanguage_folderis empty, this checks[ -f "/$language/config.lang" ]. This is likely false.whiptailbox appears asking for the path.sed -i "s/language_folder=.*/language_folder=$real_language_Folder/g" "$JDAutoConfig"runs.This seems okay if
JDAutoConfigexists. But what ifJDAutoConfigdoesn't exist?Line 3:
JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)If it's not found,
JDAutoConfigis empty.i18n.shwon't setlanguage_folder.Line 13 checks
/config.lang.Line 15 tries to
sedan empty file path? No,$JDAutoConfigis empty.sed -i ... ""will fail.However, the most obvious error is in
config.shLine 13.The variable
language_folderis used.But look at
i18n.shagain.If
JDAutoConfigis found,language_folderis set.Wait, look at
config.shLine 11:This line uses
$language.In
i18n.sh,$languageis set.Is there a typo?
In
config.sh, Line 13:In the OLD
config.sh, the variable waslanguage_Folder(Capital F).In
i18n.sh, the variable islanguage_folder(lowercase f).If
config.shrelies oni18n.shto setlanguage_folder, it works.BUT, look at
addrename.sh.It sources
i18n.sh.Look at
config.shagain.The user comment says: "fixed the missing
possiblelangfoldervariable inconfig.sh".In the OLD code:
This line existed in the OLD code.
In the NEW code:
This line exists in the NEW code.
What is missing?
In the OLD code,
language_Folderwas defined explicitly inconfig.sh.In the NEW code, it is NOT defined in
config.sh. It is expected to be defined byi18n.sh.Problem:
i18n.shis sourced.If
JDAutoConfigis NOT found,i18n.shdoes NOT setlanguage_folder.Then
config.shLine 13 uses$language_folderwhich is empty.More importantly, look at
config.shLine 15:If
$JDAutoConfigis empty (not found), this command fails.However, the main issue is likely that
language_folderis not guaranteed to be set ifJDAutoConfigis missing, and the script proceeds to use it.Let's look for a simpler typo.
In
config.sh, Line 13:In
i18n.sh,language_folderis set.Wait!
In
config.sh, the variablelanguageis used in Line 11.In
i18n.sh,languageis set.Is
languageset beforei18n.shis sourced?No.
Does
i18n.shsetlanguage?Yes.
So
config.shshould work IFJDAutoConfigexists.What if
JDAutoConfigdoes NOT exist?JDAutoConfigis empty.i18n.shis sourced.i18n.shseesJDAutoConfigis empty/unset.i18n.shdoes NOT setlanguage_folder.i18n.shsetslanguagebased onlocale.config.sh:possiblelangfolderis calculated using$language(which is set).if ! [ -f "$language_folder"/"$language"/config.lang ]; then$language_folderis empty.[ -f "/$language/config.lang" ].whiptailis called.sed -i ... "$JDAutoConfig"$JDAutoConfigis empty.sedfails.This is a logic bug, but maybe not a "syntax" error.
Let's look at
addrename.sh.Line 15:
source "$(dirname "$0")/i18n.sh"Let's look at
i18n.sh.Line 4:
SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)If
i18n.shis sourced fromconfig.sh,BASH_SOURCE[1]isconfig.sh.SCRIPT_NAMEbecomesconfig.Line 10:
language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)Let's look at
config.shagain.The user said they fixed the missing
possiblelangfolder.In the OLD code,
possiblelangfolderwas defined.In the NEW code,
possiblelangfolderis defined.Is there a typo in
config.shLine 13?In the OLD code:
The variable name changed from
language_Foldertolanguage_folder.Does
i18n.shsetlanguage_folder?Yes.
Does
config.shrely oni18n.sh?Yes.
Is there a case where
i18n.shfails to setlanguage_folder?Yes, if
JDAutoConfigis not found.But wait!
Look at
config.shLine 3:If
JDAutoConfigis not found,JDAutoConfigis empty.Then
i18n.shis sourced.Then
config.shLine 13 uses$language_folder.If
language_folderis empty, the path is/$language/config.lang.This is a bug.
However, there is a more subtle bug in
config.sh.Look at Line 11:
Look at Line 13:
If
language_folderis empty, this check is wrong.But the biggest issue is:
In
config.sh, the variablelanguage_folderis not defined locally. It relies oni18n.sh.In
i18n.sh,language_folderis only set ifJDAutoConfigexists.If
JDAutoConfigdoes NOT exist,language_folderis empty.Then
config.shtries to use$language_folder.This is a logic error.
Additionally, look at
config.shLine 15:If
$JDAutoConfigis empty, this fails.So, if
JDAutoConfigis missing,config.shbreaks.In the OLD code:
If
JDAutoConfigwas missing,grepwould fail/return empty.language_Folderwould be empty.Then
possiblelangfolderwould be calculated.Then the check
if ! [ -f "$language_Folder"/"$language"/config.lang ]would fail (empty folder).Then
whiptailwould ask for the path.Then
sedwould fail on empty$JDAutoConfig.So the OLD code also had this issue.
Is there a difference?
In the OLD code,
language_Folderwas explicitly set (to empty if grep failed).In the NEW code,
language_folderis set byi18n.sh(to empty if JDAutoConfig missing).So the behavior is similar.
Let's look for other errors.
addrename.shLine 15:
source "$(dirname "$0")/i18n.sh"jdautoenc.shLine 11:
source "$(dirname "$0")/i18n.sh"rename.shLine 13:
source "$(dirname "$0")/i18n.sh"removerename.shLine 13:
source "$(dirname "$0")/i18n.sh"i18n.shLine 4:
SCRIPT_NAME=$(basename "${BASH_SOURCE[1]}" .sh 2>/dev/null)If
i18n.shis sourced fromconfig.sh,BASH_SOURCE[1]isconfig.sh.SCRIPT_NAMEisconfig.Line 10:
language_folder=$(grep "language_folder=" "$JDAutoConfig" ...)Wait!
In
config.sh,JDAutoConfigis set on Line 3.In
i18n.sh,JDAutoConfigis used on Line 10.Is
JDAutoConfigavailable ini18n.sh?Yes, because
config.shsets it before sourcingi18n.sh.So
i18n.shshould work.Let's look at
addrename.sh.Line 10:
JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)Line 15:
source "$(dirname "$0")/i18n.sh"i18n.shusesJDAutoConfig. It is set.Let's look at
jdautoenc.sh.Line 3:
config=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)Line 6:
source "$config"Line 9:
source "$(dirname "$0")/i18n.sh"WAIT!
In
jdautoenc.sh, the variable is namedconfig, NOTJDAutoConfig.In
i18n.sh, Line 10:i18n.shexpects the variable to be namedJDAutoConfig.In
jdautoenc.sh, the variable is namedconfig.So
i18n.shwill NOT findJDAutoConfiginjdautoenc.sh.This is a bug.
Same for
rename.sh.Line 3:
config="$2"Line 6:
source "$config"Line 9:
source "$(dirname "$0")/i18n.sh"i18n.shexpectsJDAutoConfig.rename.shusesconfig.Same for
removerename.sh.Line 10:
JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)Here it IS named
JDAutoConfig. Soremoverename.shis OK.Same for
addrename.sh.Line 10:
JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)Here it IS named
JDAutoConfig. Soaddrename.shis OK.Same for
config.sh.Line 3:
JDAutoConfig=$(find ~ -type f -iname "JDAutoConfig" 2>/dev/null)Here it IS named
JDAutoConfig. Soconfig.shis OK.But
jdautoenc.shandrename.shuseconfig.This is a critical bug.
Fix:
Either rename
configtoJDAutoConfiginjdautoenc.shandrename.sh, OR updatei18n.shto check forconfigas well.Given that
JDAutoConfigis the standard name in the other scripts, it is likely thatjdautoenc.shandrename.shshould useJDAutoConfig.However,
jdautoenc.shandrename.shalsosource "$config".If
i18n.shis sourced AFTERsource "$config", thenJDAutoConfigmight be set by the config file?No,
source "$config"sources the config file. The config file does NOT setJDAutoConfig. It sets other variables.So
JDAutoConfigis NOT set injdautoenc.shorrename.sh.So
i18n.shwill fail to findlanguage_folder.This is a bug.
✅ No issues found — changes look consistent with the stated intent. Ready to be merged.
Wait, I found a bug.
Bug:
i18n.shexpects the variableJDAutoConfigto be set.config.sh,addrename.sh, andremoverename.shsetJDAutoConfig.jdautoenc.shandrename.shsetconfiginstead.i18n.shwill fail to determinelanguage_folderinjdautoenc.shandrename.sh.Fix:
In
jdautoenc.shandrename.sh, renameconfigtoJDAutoConfigOR updatei18n.shto check forconfigifJDAutoConfigis not set.Given the consistency of the other scripts, renaming
configtoJDAutoConfiginjdautoenc.shandrename.shis the recommended fix.Also, in
config.sh, Line 13:If
JDAutoConfigis not found,language_folderis empty. This check will fail. This is a logic error, but it existed in the old code too (withlanguage_Folder).I will flag the
JDAutoConfigvsconfigvariable name mismatch.Review of PR #6 — 2 low-severity issues, no blockers.
⚠️ jdautoenc.sh and rename.sh don't set
JDAutoConfigi18n.sh:14requiresJDAutoConfigto readlanguage_folder. Three scripts set it correctly (config.sh,addrename.sh,removerename.sh), butjdautoenc.sh:3andrename.sh:11useconfiginstead. Works now becausesource "$config"runs first and the JDAutoConfig file defineslanguage_folderdirectly. But if that variable is ever removed from JDAutoConfig or the source order changes, translations silently break.Fix: Add
JDAutoConfig="$config"before sourcingi18n.shin both files.⚠️
trcollides with POSIX utility —i18n.sh:30definestr(). Not a current issue but worth noting.✅ Good: Clean deduplication, self-documenting keys, solid fallback chain.
05e07a3857to4b2e40c59f@Zephyre_Review fixed the
config→JDAutoConfigvariable naming injdautoenc.shandrename.shsoi18n.shcan properly fall back to reading from the config file. Ready for re-review.✅ No issues found — changes look consistent with the stated intent. Ready to be merged.