telegram_libs 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of telegram_libs might be problematic. Click here for more details.

@@ -0,0 +1,5 @@
1
+ """
2
+ Telegram Libs - Common libraries for Telegram bots
3
+ """
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,32 @@
1
+ import json
2
+ import os
3
+
4
+ def load_translations():
5
+ translations = {}
6
+ locales_dir = os.path.join(os.path.dirname(__file__), 'locales')
7
+
8
+ for filename in os.listdir(locales_dir):
9
+ if filename.endswith('.json'):
10
+ lang = filename.split('.')[0]
11
+ with open(os.path.join(locales_dir, filename), 'r', encoding='utf-8') as f:
12
+ translations[lang] = json.load(f)
13
+
14
+ return translations
15
+
16
+ TRANSLATIONS = load_translations()
17
+
18
+ def t(key, lang='ru', **kwargs):
19
+ """Get translation for a key with optional formatting"""
20
+ try:
21
+ # Support nested keys like "buttons.start"
22
+ keys = key.split('.')
23
+ value = TRANSLATIONS[lang]
24
+ for k in keys:
25
+ value = value[k]
26
+
27
+ return value.format(**kwargs) if kwargs else value
28
+ except KeyError:
29
+ # Fallback to English if translation missing
30
+ if lang != 'en':
31
+ return t(key, 'en', **kwargs)
32
+ return key # Return the key itself as last resort
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.3
2
+ Name: telegram_libs
3
+ Version: 0.1.0
4
+ Summary: Common libraries for Telegram bots
5
+ Author: Andrey Gritsaenko gricaenko.95a@gmail.com
6
+ Requires-Python: >=3.11,<4.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Requires-Dist: pytest (>=8.3.5,<9.0.0)
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Telegram Libs
15
+
16
+ Common functionality for Andrey Gritsaenko's Telegram bots.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install telegram-libs
22
+ ```
@@ -0,0 +1,5 @@
1
+ telegram_libs/__init__.py,sha256=DA8kwbn0D6y5hd3skhhP_mQJg54ar3iK-b3c5SAfE4o,82
2
+ telegram_libs/translation.py,sha256=C9rbzNy2tJKxKrMqS06v_Rv0BgJxYgBTIe2rjcN8_hY,1012
3
+ telegram_libs-0.1.0.dist-info/METADATA,sha256=WcVDVB7yPL2yW2SQuzsbD_3I-dCtOM5j7N7RFKLbN-I,594
4
+ telegram_libs-0.1.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
5
+ telegram_libs-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.1.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any