Skip to content

Add 'samples' folder with new updated config-sample.txt and more - #1426

Open
nerun wants to merge 1 commit into
prasathmani:masterfrom
nerun:samples
Open

Add 'samples' folder with new updated config-sample.txt and more#1426
nerun wants to merge 1 commit into
prasathmani:masterfrom
nerun:samples

Conversation

@nerun

@nerun nerun commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Add 'samples' folder with new updated config-sample.txt (link updated in README), plus scripts to automatically read tinyfilemanager.php, extract translation strings and update translation.json with new strings, remove old strings don't used anymore, but keep translations of existing strings.

Description

Config sample

The default file at https://tinyfilemanager.github.io/config-sample.txt is outdated, incomplete, and inaccessible to everyone. By creating a sample folder, we can easily update it.

The new config-sample.txt file is compliant and compatible with PR #1421, which fixes some issues related to saving to the file, but it has not yet been merged.

The new file includes new settings added by PR #1276 (merged), as well as:

  • the default $CONFIG that was always missing.
  • $global_readonly and $upload_chunk_size_bytes, which already existed but were not included in the currently existing config-sample.txt.
  • new updated comment header

Diff:

2,11c2,8
< 
< /*
< #################################################################################################################
< This is an OPTIONAL configuration file. rename this file into config.php to use this configuration 
< The role of this file is to make updating of "tinyfilemanager.php" easier.
< So you can:
< -Feel free to remove completely this file and configure "tinyfilemanager.php" as a single file application.
< or
< -Put inside this file all the static configuration you want and forgot to configure "tinyfilemanager.php".
< #################################################################################################################
---
> /******************************************************************************************************
>  * This is an OPTIONAL configuration file. Rename this file to "config.php" to use this configuration.
>  * The purpose of this file is to make updating "tinyfilemanager.php" easier.
>  * You can either:
>  * - Ignore this file and configure "tinyfilemanager.php" as a single-file application.
>  * - Put all your static configuration here and avoid modifying "tinyfilemanager.php".
>  ******************************************************************************************************
13a11,17
> //Default Configuration
> $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"theme":"light"}';
> 
> // Default theme and font size for the ACE editor.
> $ace_fontsize = 12;
> $ace_theme = 'textmate';
> 
32a37,39
> // Puts the entire manager in read-only mode for all users, regardless of $readonly_users.
> $global_readonly = false;
> 
105a113,115
> 
> // chunk size 2,000,000 bytes (~2MB)
> $upload_chunk_size_bytes = 2000000;

Caution

There's one thing to consider: the $CONFIG in this version of the sample is not located directly below the <?php tag, where the current save() function expects it to be. The new sample was designed with PR #1421 (not merged yet) in mind.

Scripts for translation.json update

There are two scripts inside samples/:

  • generate_translation-sample.py
  • sync_translations.py

generate_translation-sample.py

Generate translation-sample.txt from tinyfilemanager.php.

It searches for all $tr['en'] entries and transforms them into JSON in the format expected by translation.json.

Usage:
python generate_translation-sample.py

sync_translations.py

Synchronizes translation.json with translation-sample.txt.

Features:

- Adds missing strings (using English as fallback)
- Removes obsolete strings
- Preserves existing translations
- Sorts alphabetically
- Creates backup 'translation.json.bak'
- `--check` mode (verification only)

--check mode (verify only):
python sync_translations.py --check

Example output:
    Language: pt_BR
        +3 added
        -1 removed
    Language: fr
        OK
    Language: es
        +2 added

Normal usage:
python sync_translations.py

Creates 'translation.json.bak' and updates 'translation.json'.

Warning

I could have used these scripts to create the new, updated translation.json file, but I didn't. There are several translations in the Pull Request pipeline, and that could cause confusion later. But I assure you that the scripts work fine. I also considered that updating translation.json using Python scripts provided by this PR should be done by the development team, not by a random contributor.

README), plus scripts to automatically read tinyfilemanager.php, extract
translation strings and update translation.json with new strings, remove old
strings don't used anymore, but keep translations of existing strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant