Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
490e380
feat: new string
AlexeyZavar Jun 23, 2023
08c8fb5
feat: new strings
AlexeyZavar Jun 25, 2023
f711ffa
feat: new strings
AlexeyZavar Jun 29, 2023
0b35f44
feat: new strings
AlexeyZavar Jul 10, 2023
a71e4d0
feat: new strings
AlexeyZavar Jul 17, 2023
289148a
feat: new strings
AlexeyZavar Jul 17, 2023
580315a
feat: new strings
AlexeyZavar Jul 31, 2023
b7919f0
feat: new strings
AlexeyZavar Aug 1, 2023
4285a2f
feat: new strings
AlexeyZavar Aug 1, 2023
f60d39a
feat: new strings
AlexeyZavar Aug 2, 2023
1a86dd0
feat: new strings
AlexeyZavar Aug 7, 2023
2ced6e8
feat: new strings
AlexeyZavar Aug 7, 2023
7615a5c
feat: new strings
AlexeyZavar Aug 9, 2023
a33795f
feat: new strings
AlexeyZavar Aug 9, 2023
8cce4ba
feat: new strings
AlexeyZavar Aug 28, 2023
9c5ca2d
feat: new strings
AlexeyZavar Aug 28, 2023
cec5b55
feat: new strings
AlexeyZavar Aug 30, 2023
d4d498b
feat: new strings
AlexeyZavar Sep 1, 2023
828e85e
feat: new strings
AlexeyZavar Sep 3, 2023
e42f11f
feat: new strings
AlexeyZavar Sep 3, 2023
bf66dd4
feat: new strings
AlexeyZavar Sep 3, 2023
ab209be
feat: new strings
AlexeyZavar Sep 6, 2023
f79df27
feat: new strings
AlexeyZavar Sep 17, 2023
2f9851e
feat: new strings
AlexeyZavar Sep 20, 2023
d850250
feat: new strings
AlexeyZavar Sep 21, 2023
bf3608f
fix: don't hardcode languages
AlexeyZavar Sep 21, 2023
f634a1c
feat: new strings
AlexeyZavar Sep 27, 2023
55f954a
feat: new strings
AlexeyZavar Sep 29, 2023
fc4513e
feat: new strings
AlexeyZavar Sep 29, 2023
ff7d4c0
feat: new strings
AlexeyZavar Sep 30, 2023
eda47ba
feat: new strings
AlexeyZavar Oct 2, 2023
5361a2e
feat: new strings
AlexeyZavar Oct 8, 2023
d9fbbbc
feat: new strings
AlexeyZavar Oct 27, 2023
1c8f2e6
fix: typo
AlexeyZavar Oct 28, 2023
66fb4b8
feat: new strings
AlexeyZavar Oct 29, 2023
3e74e4c
feat: new strings
AlexeyZavar Nov 6, 2023
46b9dc3
feat: new strings
AlexeyZavar Nov 10, 2023
46704d4
feat: new strings
AlexeyZavar Dec 1, 2023
c76fb14
feat: new strings
AlexeyZavar Dec 15, 2023
08e50f4
feat: new strings
AlexeyZavar Dec 16, 2023
ffdc8b4
feat: new strings
AlexeyZavar Dec 27, 2023
b4ae203
feat: new strings
AlexeyZavar Dec 30, 2023
b282329
feat: new strings
AlexeyZavar Dec 31, 2023
2b4c59b
feat: new strings
AlexeyZavar Dec 31, 2023
60afcc8
feat: new strings
AlexeyZavar Jan 2, 2024
14127c0
feat: new strings
AlexeyZavar Jan 3, 2024
e369cc9
feat: new strings
AlexeyZavar Jan 3, 2024
d657ba7
feat: new strings
AlexeyZavar Jan 4, 2024
f56e64f
feat: new strings
AlexeyZavar Jan 4, 2024
8072ceb
feat: new strings
AlexeyZavar Jan 8, 2024
54d1773
feat: new strings
AlexeyZavar Jan 17, 2024
f162762
feat: new strings
AlexeyZavar Jan 21, 2024
c202608
feat: new strings
AlexeyZavar Jan 25, 2024
a5fa0a4
feat: new strings
AlexeyZavar Jan 25, 2024
ec07ded
feat: new strings
AlexeyZavar Jan 26, 2024
d35caa1
feat: new strings
AlexeyZavar Jan 29, 2024
8abca89
feat: new strings
AlexeyZavar Feb 4, 2024
20662ce
feat: new strings
AlexeyZavar Feb 4, 2024
53bbfaf
feat: new strings
AlexeyZavar Feb 7, 2024
069cad5
feat: new strings
AlexeyZavar Feb 16, 2024
4b61106
feat: new strings
AlexeyZavar Feb 20, 2024
5df38b2
feat: new strings
AlexeyZavar Feb 29, 2024
59fa77c
feat: new strings
AlexeyZavar Mar 3, 2024
159ca39
feat: new strings
AlexeyZavar Mar 24, 2024
29d7b39
feat: new strings
AlexeyZavar Apr 1, 2024
ad7a4b4
feat: new strings
AlexeyZavar Apr 1, 2024
dba23ab
feat: new strings
AlexeyZavar May 3, 2024
4475301
feat: new strings
AlexeyZavar Jul 1, 2024
cd55261
feat: new strings
AlexeyZavar Jul 1, 2024
b7d0fc8
feat: new strings
AlexeyZavar Jul 2, 2024
2d2d01b
feat: new strings
AlexeyZavar Sep 12, 2024
b93731a
feat: new strings
AlexeyZavar Oct 30, 2024
2ab23a4
feat: new strings
AlexeyZavar Nov 23, 2024
24c6105
feat: new strings
AlexeyZavar Nov 29, 2024
774587e
feat: new strings
AlexeyZavar Nov 30, 2024
819b475
feat: new strings
AlexeyZavar Dec 29, 2024
632d406
feat: new strings
AlexeyZavar Dec 31, 2024
d91faeb
feat: new strings
AlexeyZavar Jan 17, 2025
8a239ad
fix: weird issue with formatting
AlexeyZavar Jan 18, 2025
a109720
feat: new strings
AlexeyZavar Apr 14, 2025
b193bcb
fix: grammar issues
AlexeyZavar Apr 14, 2025
bb01be2
feat: new strings
AlexeyZavar Apr 15, 2025
a8eff20
fix: typo
AlexeyZavar Apr 15, 2025
daf5710
feat: new strings
AlexeyZavar Apr 24, 2025
9651001
feat: new strings
AlexeyZavar May 4, 2025
3b2d6c1
feat: new strings
AlexeyZavar Jun 8, 2025
c4aa3df
feat: new strings
AlexeyZavar Jun 8, 2025
e9cd24b
feat: new strings
AlexeyZavar Jun 8, 2025
8dfd9a4
feat: new strings
AlexeyZavar Jun 12, 2025
4a4d9a1
fix: Hebrew language code
AlexeyZavar Jun 22, 2025
a981d5e
feat: new strings
AlexeyZavar Jul 6, 2025
a50e0f4
feat: new strings
AlexeyZavar Jul 6, 2025
b76f021
fix: pluralized strings
AlexeyZavar Sep 28, 2025
a0fc4a5
added kk strings
biscript Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions scripts/generate-android.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import re

from lxml import etree as et

import json
import os.path

mappings = {
'zh-hans': 'zh-rCN',
'zh-hant': 'zh-rTW',
'he': 'iw'
}

if not os.path.exists('./values'):
os.chdir('../')

langs = [
'en',
'ru',
'be',
'pt',
'es',
'uk'
]
langs = [f for f in os.listdir('./values/langs') if os.path.isdir(f'./values/langs/{f}')]
langs.sort()

if not os.path.exists('./out'):
os.mkdir('./out')
Expand All @@ -28,17 +30,38 @@
root = et.Element('resources')

for k, v in strings.items():
if k + '_Android' in strings:
continue

if k.endswith('_PC'):
continue

if k.endswith('_Android'):
k = k.replace('_Android', '')

if k == 'HideAllChats':
continue

string = et.SubElement(root, 'string', {'name': k})
string.text = v
string.text = v.replace('\'', '\\\'')

tree = et.ElementTree(root)

lang = mappings.get(lang, lang)
suffix = f'-{lang}' if lang != 'en' else ''

if not os.path.exists(f'./out/android/values{suffix}'):
os.mkdir(f'./out/android/values{suffix}')

tree.write(f'./out/android/values{suffix}/ayu.xml', pretty_print=True, xml_declaration=True, encoding="utf-8")
tree.write(f'./out/android/values{suffix}/ayu.xml', pretty_print=True, xml_declaration=True, encoding='utf-8')

# fix CDATA
with open(f'./out/android/values{suffix}/ayu.xml', encoding='utf-8') as f:
data = f.read()
data = re.sub(r'&lt;!\[CDATA\[&lt;a href="(.+?)"&gt;(.+?)&lt;/a&gt;\]\]&gt;', r'<![CDATA[<a href="\1">\2</a>]]>', data)

with open(f'./out/android/values{suffix}/ayu.xml', 'w', encoding='utf-8') as f:
f.write(data)

print(f'Processed "{lang}"')

Expand Down
39 changes: 36 additions & 3 deletions scripts/generate-desktop.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import json
import os.path
import re

import requests

if not os.path.exists('./values'):
os.chdir('../')

with open('./values/langs/en/Shared.json') as f:
with open('./values/langs/en/Shared.json', encoding='utf-8') as f:
strings = json.load(f)


def parse_latest_tag():
r = requests.get('https://github.com/telegramdesktop/tdesktop/tags')
regex = re.compile(r'<a href="/telegramdesktop/tdesktop/releases/tag/(.*?)"')

try:
return regex.search(r.text).group(1)
except:
return None


req = requests.get(
'https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/langs/lang.strings'
f'https://raw.githubusercontent.com/telegramdesktop/tdesktop/{parse_latest_tag()}/Telegram/Resources/langs/lang.strings'
)

data = req.text
Expand All @@ -21,7 +33,28 @@
'''

for k, v in strings.items():
escaped = v.replace('"', '\\"')
if k.endswith('_Android'):
continue

if k.endswith('_PC'):
k = k.replace('_PC', '')

if any(item in k for item in ["_zero", "_two", "_few", "_many"]):
continue

if k.endswith('_one'):
k = k.replace('_one', '#one')
elif k.endswith('_other'):
k = k.replace('_other', '#other')

if '%1$d' in v and not '%2$d' in v:
v = v.replace('%1$d', '{count}')
elif '%1$d' in v and '%2$d' in v:
v = v.replace('%1$d', '{count1}').replace('%2$d', '{count2}')
elif '%1$s' in v:
v = v.replace('%1$s', '{item}')

escaped = v.replace('"', '\\"').replace('\n', '\\n')
data += f'"ayu_{k}" = "{escaped}";\n'

if not os.path.exists('./out'):
Expand Down
Loading