Skip to content

Commit fc8f30d

Browse files
✨ Add locales adjustement for folder names (#256)
1 parent 7db86bd commit fc8f30d

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

paperless-ngx/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ schema:
6666
usermap_gid: int?
6767
ingress_auth: bool
6868
tika_gotenberg: bool
69+
locales: str?

paperless-ngx/rootfs/etc/s6-overlay/s6-rc.d/init-paperless/run

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,21 @@ bashio::var.json \
9696
| tempio \
9797
-template /etc/s6-overlay/s6-rc.d/init-paperless/supervisord.gtpl \
9898
-out /etc/supervisord.conf
99+
100+
# Update locales
101+
if bashio::config.has_value 'locales'; then
102+
bashio::log.info "Setting up locales"
103+
apt-get update -y
104+
apt-get install -y locales patch
105+
locales=$(bashio::config 'locales')
106+
echo -n "${locales}.UTF-8 UTF-8" > /etc/locale.gen
107+
locale-gen ${locales}.UTF-8
108+
update-locale ${locales}.UTF-8
109+
dpkg-reconfigure --frontend=noninteractive locales
110+
bashio::log.info "Patching file_handler.py to use ${locales} as default"
111+
cd /usr/src/paperless/
112+
patch -p1 < /patches/file_handling.patch
113+
echo -n "${locales}".UTF-8 > /var/run/s6/container_environment/LC_ALL
114+
echo -n "${locales}".UTF-8 > /var/run/s6/container_environment/LANG
115+
echo -n "${locales}".UTF-8 > /var/run/s6/container_environment/LANGUAGE
116+
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/src/documents/file_handling.py b/src/documents/file_handling.py
2+
index 3d1a643..81a863d 100755
3+
--- a/src/documents/file_handling.py
4+
+++ b/src/documents/file_handling.py
5+
@@ -3,6 +3,12 @@ import os
6+
from django.conf import settings
7+
8+
from documents.models import Document
9+
+import locale
10+
+
11+
+locale_setting = os.getenv('LC_ALL')
12+
+if locale_setting is None:
13+
+ locale_setting = 'en_US.UTF8'
14+
+locale.setlocale(locale.LC_ALL, locale_setting)
15+
from documents.templating.filepath import validate_filepath_template_and_render
16+
from documents.templating.utils import convert_format_str_to_template_format
17+

paperless-ngx/translations/en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,8 @@ configuration:
6161
tika_gotenberg:
6262
name: Enable Tika Gotenberg
6363
description: You need to install the Tika Gotenberg addon
64+
locales:
65+
name: Locales
66+
description: Your language (fr_FR, en_US, de_DE, etc)
6467
network:
6568
80/tcp: Web interface (Not required for Ingress)

0 commit comments

Comments
 (0)