Update progress of language (#1029)
This commit is contained in:
parent
1cf23b3542
commit
74a0574462
2 changed files with 179 additions and 31 deletions
88
README.md
88
README.md
|
@ -1,5 +1,5 @@
|
||||||
<p align="center"><img src="https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/main/docs/stirling.png" width="80" ><br><h1 align="center">Stirling-PDF</h1>
|
<p align="center"><img src="https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/main/docs/stirling.png" width="80" ></p>
|
||||||
</p>
|
<h1 align="center">Stirling-PDF</h1>
|
||||||
|
|
||||||
[![Docker Pulls](https://img.shields.io/docker/pulls/frooodle/s-pdf)](https://hub.docker.com/r/frooodle/s-pdf)
|
[![Docker Pulls](https://img.shields.io/docker/pulls/frooodle/s-pdf)](https://hub.docker.com/r/frooodle/s-pdf)
|
||||||
[![Discord](https://img.shields.io/discord/1068636748814483718?label=Discord)](https://discord.gg/Cn8pWhQRxZ)
|
[![Discord](https://img.shields.io/discord/1068636748814483718?label=Discord)](https://discord.gg/Cn8pWhQRxZ)
|
||||||
|
@ -19,16 +19,17 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
||||||
![stirling-home](images/stirling-home.jpg)
|
![stirling-home](images/stirling-home.jpg)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Dark mode support.
|
- Dark mode support.
|
||||||
- Custom download options (see [here](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/images/settings.png) for example)
|
- Custom download options (see [here](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/images/settings.png) for example)
|
||||||
- Parallel file processing and downloads
|
- Parallel file processing and downloads
|
||||||
- API for integration with external scripts
|
- API for integration with external scripts
|
||||||
- Optional Login and Authentication support (see [here](https://github.com/Stirling-Tools/Stirling-PDF/tree/main#login-authentication) for documentation)
|
- Optional Login and Authentication support (see [here](https://github.com/Stirling-Tools/Stirling-PDF/tree/main#login-authentication) for documentation)
|
||||||
|
|
||||||
|
|
||||||
## **PDF Features**
|
## **PDF Features**
|
||||||
|
|
||||||
### **Page Operations**
|
### **Page Operations**
|
||||||
|
|
||||||
- View and modify PDFs - View multi page PDFs with custom viewing sorting and searching. Plus on page edit features like annotate, draw and adding text and images. (Using PDF.js with Joxit and Liberation.Liberation fonts)
|
- View and modify PDFs - View multi page PDFs with custom viewing sorting and searching. Plus on page edit features like annotate, draw and adding text and images. (Using PDF.js with Joxit and Liberation.Liberation fonts)
|
||||||
- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages.
|
- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages.
|
||||||
- Merge multiple PDFs together into a single resultant file.
|
- Merge multiple PDFs together into a single resultant file.
|
||||||
|
@ -45,6 +46,7 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
||||||
- Convert PDF to a single page.
|
- Convert PDF to a single page.
|
||||||
|
|
||||||
### **Conversion Operations**
|
### **Conversion Operations**
|
||||||
|
|
||||||
- Convert PDFs to and from images.
|
- Convert PDFs to and from images.
|
||||||
- Convert any common file to PDF (using LibreOffice).
|
- Convert any common file to PDF (using LibreOffice).
|
||||||
- Convert PDF to Word/Powerpoint/Others (using LibreOffice).
|
- Convert PDF to Word/Powerpoint/Others (using LibreOffice).
|
||||||
|
@ -53,6 +55,7 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
||||||
- Markdown to PDF.
|
- Markdown to PDF.
|
||||||
|
|
||||||
### **Security & Permissions**
|
### **Security & Permissions**
|
||||||
|
|
||||||
- Add and remove passwords.
|
- Add and remove passwords.
|
||||||
- Change/set PDF Permissions.
|
- Change/set PDF Permissions.
|
||||||
- Add watermark(s).
|
- Add watermark(s).
|
||||||
|
@ -61,6 +64,7 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
||||||
- Auto-redact text.
|
- Auto-redact text.
|
||||||
|
|
||||||
### **Other Operations**
|
### **Other Operations**
|
||||||
|
|
||||||
- Add/Generate/Write signatures.
|
- Add/Generate/Write signatures.
|
||||||
- Repair PDFs.
|
- Repair PDFs.
|
||||||
- Detect and remove blank pages.
|
- Detect and remove blank pages.
|
||||||
|
@ -77,11 +81,11 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
||||||
- Flatten PDFs.
|
- Flatten PDFs.
|
||||||
- Get all information on a PDF to view or export as JSON.
|
- Get all information on a PDF to view or export as JSON.
|
||||||
|
|
||||||
|
|
||||||
For a overview of the tasks and the technology each uses please view [Endpoint-groups.md](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/Endpoint-groups.md)
|
For a overview of the tasks and the technology each uses please view [Endpoint-groups.md](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/Endpoint-groups.md)
|
||||||
Demo of the app is available [here](https://stirlingpdf.io). username: demo, password: demo
|
Demo of the app is available [here](https://stirlingpdf.io). username: demo, password: demo
|
||||||
|
|
||||||
## Technologies used
|
## Technologies used
|
||||||
|
|
||||||
- Spring Boot + Thymeleaf
|
- Spring Boot + Thymeleaf
|
||||||
- [PDFBox](https://github.com/apache/pdfbox/tree/trunk)
|
- [PDFBox](https://github.com/apache/pdfbox/tree/trunk)
|
||||||
- [LibreOffice](https://www.libreoffice.org/discover/libreoffice/) for advanced conversions
|
- [LibreOffice](https://www.libreoffice.org/discover/libreoffice/) for advanced conversions
|
||||||
|
@ -94,9 +98,11 @@ Demo of the app is available [here](https://stirlingpdf.io). username: demo, pas
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
### Locally
|
### Locally
|
||||||
|
|
||||||
Please view https://github.com/Stirling-Tools/Stirling-PDF/blob/main/LocalRunGuide.md
|
Please view https://github.com/Stirling-Tools/Stirling-PDF/blob/main/LocalRunGuide.md
|
||||||
|
|
||||||
### Docker / Podman
|
### Docker / Podman
|
||||||
|
|
||||||
https://hub.docker.com/r/frooodle/s-pdf
|
https://hub.docker.com/r/frooodle/s-pdf
|
||||||
|
|
||||||
Stirling PDF has 2 different versions, a Full version and ultra-Lite version. Depending on the types of features you use you may want a smaller image to save on space.
|
Stirling PDF has 2 different versions, a Full version and ultra-Lite version. Depending on the types of features you use you may want a smaller image to save on space.
|
||||||
|
@ -106,6 +112,7 @@ For people that don't mind about space optimization just use the latest tag.
|
||||||
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest-ultra-lite?label=Stirling-PDF%20Ultra-Lite)
|
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest-ultra-lite?label=Stirling-PDF%20Ultra-Lite)
|
||||||
|
|
||||||
Docker Run
|
Docker Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 8080:8080 \
|
-p 8080:8080 \
|
||||||
|
@ -122,7 +129,9 @@ docker run -d \
|
||||||
|
|
||||||
-v /location/of/customFiles:/customFiles \
|
-v /location/of/customFiles:/customFiles \
|
||||||
```
|
```
|
||||||
|
|
||||||
Docker Compose
|
Docker Compose
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
|
@ -143,54 +152,60 @@ services:
|
||||||
Note: Podman is CLI-compatible with Docker, so simply replace "docker" with "podman".
|
Note: Podman is CLI-compatible with Docker, so simply replace "docker" with "podman".
|
||||||
|
|
||||||
## Enable OCR/Compression feature
|
## Enable OCR/Compression feature
|
||||||
|
|
||||||
Please view https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToUseOCR.md
|
Please view https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToUseOCR.md
|
||||||
|
|
||||||
## Supported Languages
|
## Supported Languages
|
||||||
|
|
||||||
Stirling PDF currently supports 26!
|
Stirling PDF currently supports 26!
|
||||||
- English (English) (en_GB)
|
|
||||||
- English (US) (en_US)
|
| Language | Progress |
|
||||||
- Arabic (العربية) (ar_AR)
|
| ------------------------------------------- | -------------------------------------- |
|
||||||
- German (Deutsch) (de_DE)
|
| English (English) (en_GB) | ![100%](https://geps.dev/progress/100) |
|
||||||
- French (Français) (fr_FR)
|
| English (US) (en_US) | ![100%](https://geps.dev/progress/100) |
|
||||||
- Spanish (Español) (es_ES)
|
| Arabic (العربية) (ar_AR) | ![58%](https://geps.dev/progress/58) |
|
||||||
- Simplified Chinese (简体中文) (zh_CN)
|
| German (Deutsch) (de_DE) | ![95%](https://geps.dev/progress/95) |
|
||||||
- Traditional Chinese (繁體中文) (zh_TW)
|
| French (Français) (fr_FR) | ![99%](https://geps.dev/progress/99) |
|
||||||
- Catalan (Català) (ca_CA)
|
| Spanish (Español) (es_ES) | ![95%](https://geps.dev/progress/95) |
|
||||||
- Italian (Italiano) (it_IT)
|
| Simplified Chinese (简体中文) (zh_CN) | ![99%](https://geps.dev/progress/99) |
|
||||||
- Swedish (Svenska) (sv_SE)
|
| Traditional Chinese (繁體中文) (zh_TW) | ![97%](https://geps.dev/progress/97) |
|
||||||
- Polish (Polski) (pl_PL)
|
| Catalan (Català) (ca_CA) | ![65%](https://geps.dev/progress/65) |
|
||||||
- Romanian (Română) (ro_RO)
|
| Italian (Italiano) (it_IT) | ![99%](https://geps.dev/progress/99) |
|
||||||
- Korean (한국어) (ko_KR)
|
| Swedish (Svenska) (sv_SE) | ![58%](https://geps.dev/progress/58) |
|
||||||
- Portuguese Brazilian (Português) (pt_BR)
|
| Polish (Polski) (pl_PL) | ![60%](https://geps.dev/progress/60) |
|
||||||
- Russian (Русский) (ru_RU)
|
| Romanian (Română) (ro_RO) | ![58%](https://geps.dev/progress/58) |
|
||||||
- Basque (Euskara) (eu_ES)
|
| Korean (한국어) (ko_KR) | ![92%](https://geps.dev/progress/92) |
|
||||||
- Japanese (日本語) (ja_JP)
|
| Portuguese Brazilian (Português) (pt_BR) | ![74%](https://geps.dev/progress/74) |
|
||||||
- Dutch (Nederlands) (nl_NL)
|
| Russian (Русский) (ru_RU) | ![92%](https://geps.dev/progress/92) |
|
||||||
- Greek (el_GR)
|
| Basque (Euskara) (eu_ES) | ![76%](https://geps.dev/progress/76) |
|
||||||
- Turkish (Türkçe) (tr_TR)
|
| Japanese (日本語) (ja_JP) | ![92%](https://geps.dev/progress/92) |
|
||||||
- Indonesia (Bahasa Indonesia) (id_ID)
|
| Dutch (Nederlands) (nl_NL) | ![92%](https://geps.dev/progress/92) |
|
||||||
- Hindi (हिंदी) (hi_IN)
|
| Greek (Ελληνικά) (el_GR) | ![77%](https://geps.dev/progress/77) |
|
||||||
- Hungarian (Magyar) (hu_HU)
|
| Turkish (Türkçe) (tr_TR) | ![82%](https://geps.dev/progress/82) |
|
||||||
- Bulgarian (Български) (bg_BG)
|
| Indonesia (Bahasa Indonesia) (id_ID) | ![87%](https://geps.dev/progress/87) |
|
||||||
- Sebian Latin alphabet (Srpski) (sr_LATN_RS)
|
| Hindi (हिंदी) (hi_IN) | ![88%](https://geps.dev/progress/88) |
|
||||||
|
| Hungarian (Magyar) (hu_HU) | ![87%](https://geps.dev/progress/87) |
|
||||||
|
| Bulgarian (Български) (bg_BG) | ![82%](https://geps.dev/progress/82) |
|
||||||
|
| Sebian Latin alphabet (Srpski) (sr_LATN_RS) | ![89%](https://geps.dev/progress/89) |
|
||||||
|
|
||||||
## Contributing (creating issues, translations, fixing bugs, etc.)
|
## Contributing (creating issues, translations, fixing bugs, etc.)
|
||||||
|
|
||||||
Please see our [Contributing Guide](CONTRIBUTING.md)!
|
Please see our [Contributing Guide](CONTRIBUTING.md)!
|
||||||
|
|
||||||
## Customisation
|
## Customisation
|
||||||
|
|
||||||
Stirling PDF allows easy customization of the app.
|
Stirling PDF allows easy customization of the app.
|
||||||
Includes things like
|
Includes things like
|
||||||
|
|
||||||
- Custom application name
|
- Custom application name
|
||||||
- Custom slogans, icons, images, and even custom HTML (via file overrides)
|
- Custom slogans, icons, images, and even custom HTML (via file overrides)
|
||||||
|
|
||||||
|
|
||||||
There are two options for this, either using the generated settings file ``settings.yml``
|
There are two options for this, either using the generated settings file ``settings.yml``
|
||||||
This file is located in the ``/configs`` directory and follows standard YAML formatting
|
This file is located in the ``/configs`` directory and follows standard YAML formatting
|
||||||
|
|
||||||
Environment variables are also supported and would override the settings file
|
Environment variables are also supported and would override the settings file
|
||||||
For example in the settings.yml you have
|
For example in the settings.yml you have
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
system:
|
system:
|
||||||
defaultLocale: 'en-US'
|
defaultLocale: 'en-US'
|
||||||
|
@ -199,6 +214,7 @@ system:
|
||||||
To have this via an environment variable you would have ``SYSTEM_DEFAULTLOCALE``
|
To have this via an environment variable you would have ``SYSTEM_DEFAULTLOCALE``
|
||||||
|
|
||||||
The Current list of settings is
|
The Current list of settings is
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
security:
|
security:
|
||||||
enableLogin: false # set to 'true' to enable login
|
enableLogin: false # set to 'true' to enable login
|
||||||
|
@ -221,24 +237,31 @@ endpoints:
|
||||||
metrics:
|
metrics:
|
||||||
enabled: true # 'true' to enable Info APIs endpoints (view http://localhost:8080/swagger-ui/index.html#/API to learn more), 'false' to disable
|
enabled: true # 'true' to enable Info APIs endpoints (view http://localhost:8080/swagger-ui/index.html#/API to learn more), 'false' to disable
|
||||||
```
|
```
|
||||||
|
|
||||||
### Extra notes
|
### Extra notes
|
||||||
|
|
||||||
- Endpoints. Currently, the endpoints ENDPOINTS_TO_REMOVE and GROUPS_TO_REMOVE can include comma separate lists of endpoints and groups to disable as example ENDPOINTS_TO_REMOVE=img-to-pdf,remove-pages would disable both image-to-pdf and remove pages, GROUPS_TO_REMOVE=LibreOffice Would disable all things that use LibreOffice. You can see a list of all endpoints and groups [here](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/Endpoint-groups.md)
|
- Endpoints. Currently, the endpoints ENDPOINTS_TO_REMOVE and GROUPS_TO_REMOVE can include comma separate lists of endpoints and groups to disable as example ENDPOINTS_TO_REMOVE=img-to-pdf,remove-pages would disable both image-to-pdf and remove pages, GROUPS_TO_REMOVE=LibreOffice Would disable all things that use LibreOffice. You can see a list of all endpoints and groups [here](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/Endpoint-groups.md)
|
||||||
- customStaticFilePath. Customise static files such as the app logo by placing files in the /customFiles/static/ directory. An example of customising app logo is placing a /customFiles/static/favicon.svg to override current SVG. This can be used to change any images/icons/css/fonts/js etc in Stirling-PDF
|
- customStaticFilePath. Customise static files such as the app logo by placing files in the /customFiles/static/ directory. An example of customising app logo is placing a /customFiles/static/favicon.svg to override current SVG. This can be used to change any images/icons/css/fonts/js etc in Stirling-PDF
|
||||||
|
|
||||||
### Environment only parameters
|
### Environment only parameters
|
||||||
|
|
||||||
- ``SYSTEM_ROOTURIPATH`` ie set to ``/pdf-app`` to Set the application's root URI to ``localhost:8080/pdf-app``
|
- ``SYSTEM_ROOTURIPATH`` ie set to ``/pdf-app`` to Set the application's root URI to ``localhost:8080/pdf-app``
|
||||||
- ``SYSTEM_CONNECTIONTIMEOUTMINUTES`` to set custom connection timeout values
|
- ``SYSTEM_CONNECTIONTIMEOUTMINUTES`` to set custom connection timeout values
|
||||||
- ``DOCKER_ENABLE_SECURITY`` to tell docker to download security jar (required as true for auth login)
|
- ``DOCKER_ENABLE_SECURITY`` to tell docker to download security jar (required as true for auth login)
|
||||||
- ``INSTALL_BOOK_AND_ADVANCED_HTML_OPS`` to download calibre onto stirling-pdf enabling pdf to/from book and advanced html conversion
|
- ``INSTALL_BOOK_AND_ADVANCED_HTML_OPS`` to download calibre onto stirling-pdf enabling pdf to/from book and advanced html conversion
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
For those wanting to use Stirling-PDFs backend API to link with their own custom scripting to edit PDFs you can view all existing API documentation
|
For those wanting to use Stirling-PDFs backend API to link with their own custom scripting to edit PDFs you can view all existing API documentation
|
||||||
[here](https://app.swaggerhub.com/apis-docs/Stirling-Tools/Stirling-PDF/) or navigate to /swagger-ui/index.html of your stirling-pdf instance for your versions documentation (Or by following the API button in your settings of Stirling-PDF)
|
[here](https://app.swaggerhub.com/apis-docs/Stirling-Tools/Stirling-PDF/) or navigate to /swagger-ui/index.html of your stirling-pdf instance for your versions documentation (Or by following the API button in your settings of Stirling-PDF)
|
||||||
|
|
||||||
|
|
||||||
## Login authentication
|
## Login authentication
|
||||||
|
|
||||||
![stirling-login](images/login-light.png)
|
![stirling-login](images/login-light.png)
|
||||||
|
|
||||||
### Prerequisites:
|
### Prerequisites:
|
||||||
|
|
||||||
- User must have the folder ./configs volumed within docker so that it is retained during updates.
|
- User must have the folder ./configs volumed within docker so that it is retained during updates.
|
||||||
- Docker uses must download the security jar version by setting ``DOCKER_ENABLE_SECURITY`` to ``true`` in environment variables.
|
- Docker uses must download the security jar version by setting ``DOCKER_ENABLE_SECURITY`` to ``true`` in environment variables.
|
||||||
- Then either enable login via the settings.yml file or via setting ``SECURITY_ENABLE_LOGIN`` to ``true``
|
- Then either enable login via the settings.yml file or via setting ``SECURITY_ENABLE_LOGIN`` to ``true``
|
||||||
|
@ -257,6 +280,7 @@ For API usage you must provide a header with 'X-API-Key' and the associated API
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
### Q1: What are your planned features?
|
### Q1: What are your planned features?
|
||||||
|
|
||||||
- Progress bar/Tracking
|
- Progress bar/Tracking
|
||||||
- Full custom logic pipelines to combine multiple operations together.
|
- Full custom logic pipelines to combine multiple operations together.
|
||||||
- Folder support with auto scanning to perform operations on
|
- Folder support with auto scanning to perform operations on
|
||||||
|
@ -266,7 +290,9 @@ For API usage you must provide a header with 'X-API-Key' and the associated API
|
||||||
- Fill forms manually or automatically
|
- Fill forms manually or automatically
|
||||||
|
|
||||||
### Q2: Why is my application downloading .htm files?
|
### Q2: Why is my application downloading .htm files?
|
||||||
|
|
||||||
This is an issue caused commonly by your NGINX configuration. The default file upload size for NGINX is 1MB, you need to add the following in your Nginx sites-available file. ``client_max_body_size SIZE;`` Where "SIZE" is 50M for example for 50MB files.
|
This is an issue caused commonly by your NGINX configuration. The default file upload size for NGINX is 1MB, you need to add the following in your Nginx sites-available file. ``client_max_body_size SIZE;`` Where "SIZE" is 50M for example for 50MB files.
|
||||||
|
|
||||||
### Q3: Why is my download timing out
|
### Q3: Why is my download timing out
|
||||||
|
|
||||||
NGINX has timeout values by default so if you are running Stirling-PDF behind NGINX you may need to set a timeout value such as adding the config ``proxy_read_timeout 3600;``
|
NGINX has timeout values by default so if you are running Stirling-PDF behind NGINX you may need to set a timeout value such as adding the config ``proxy_read_timeout 3600;``
|
||||||
|
|
122
scripts/counter_translation.py
Normal file
122
scripts/counter_translation.py
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
"""A script to update language progress status in README.md based on
|
||||||
|
properties file comparison.
|
||||||
|
|
||||||
|
This script compares default properties file with others in a directory to
|
||||||
|
determine language progress.
|
||||||
|
It then updates README.md based on provided progress list.
|
||||||
|
|
||||||
|
Author: Ludy87
|
||||||
|
|
||||||
|
Example:
|
||||||
|
To use this script, simply run it from command line:
|
||||||
|
$ python counter_translation.py
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import re
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
def write_readme(progress_list: List[Tuple[str, int]]) -> None:
|
||||||
|
"""
|
||||||
|
Updates the progress status in the README.md file based
|
||||||
|
on the provided progress list.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
progress_list (List[Tuple[str, int]]): A list of tuples containing
|
||||||
|
language and progress percentage.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
with open("README.md", "r", encoding="utf-8") as file:
|
||||||
|
content = file.read()
|
||||||
|
|
||||||
|
lines = content.split("\n")
|
||||||
|
for i, line in enumerate(lines[2:], start=2):
|
||||||
|
for progress in progress_list:
|
||||||
|
language, value = progress
|
||||||
|
if language in line:
|
||||||
|
match = re.search(r"\!\[(\d+(\.\d+)?)%\]\(.*\)", line)
|
||||||
|
if match:
|
||||||
|
lines[i] = line.replace(
|
||||||
|
match.group(0),
|
||||||
|
f"![{value}%](https://geps.dev/progress/{value})",
|
||||||
|
)
|
||||||
|
|
||||||
|
new_content = "\n".join(lines)
|
||||||
|
|
||||||
|
with open("README.md", "w", encoding="utf-8") as file:
|
||||||
|
file.write(new_content)
|
||||||
|
|
||||||
|
|
||||||
|
def compare_files(default_file_path, files_directory) -> List[Tuple[str, int]]:
|
||||||
|
"""
|
||||||
|
Compares the default properties file with other
|
||||||
|
properties files in the directory.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
default_file_path (str): The path to the default properties file.
|
||||||
|
files_directory (str): The directory containing other properties files.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[Tuple[str, int]]: A list of tuples containing
|
||||||
|
language and progress percentage.
|
||||||
|
"""
|
||||||
|
file_paths = glob.glob(os.path.join(files_directory, "messages_*.properties"))
|
||||||
|
num_lines = sum(1 for _ in open(default_file_path, encoding="utf-8"))
|
||||||
|
|
||||||
|
result_list = []
|
||||||
|
|
||||||
|
for file_path in file_paths:
|
||||||
|
language = (
|
||||||
|
os.path.basename(file_path)
|
||||||
|
.split("messages_", 1)[1]
|
||||||
|
.split(".properties", 1)[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
fails = 0
|
||||||
|
if "en_GB" in language or "en_US" in language:
|
||||||
|
result_list.append(("en_GB", 100))
|
||||||
|
result_list.append(("en_US", 100))
|
||||||
|
continue
|
||||||
|
|
||||||
|
with open(default_file_path, "r", encoding="utf-8") as default_file, open(
|
||||||
|
file_path, "r", encoding="utf-8"
|
||||||
|
) as file:
|
||||||
|
for _ in range(5):
|
||||||
|
next(default_file)
|
||||||
|
try:
|
||||||
|
next(file)
|
||||||
|
except StopIteration:
|
||||||
|
fails = num_lines
|
||||||
|
|
||||||
|
for _, (line_default, line_file) in enumerate(
|
||||||
|
zip(default_file, file), start=6
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
if (
|
||||||
|
line_default.split("=", 1)[1].strip()
|
||||||
|
== line_file.split("=", 1)[1].strip()
|
||||||
|
):
|
||||||
|
fails += 1
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
result_list.append(
|
||||||
|
(
|
||||||
|
language,
|
||||||
|
int((num_lines - fails) * 100 / num_lines),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
unique_data = list(set(result_list))
|
||||||
|
unique_data.sort(key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
|
return unique_data
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
directory = os.path.join(os.getcwd(), "src", "main", "resources")
|
||||||
|
reference_file = os.path.join(directory, "messages_en_GB.properties")
|
||||||
|
write_readme(compare_files(reference_file, directory))
|
Loading…
Reference in a new issue