Skip to content

Commit 18ecf62

Browse files
committed
Translate stdlib2 and parts of stdlib
1 parent 65dc650 commit 18ecf62

2 files changed

Lines changed: 335 additions & 140 deletions

File tree

tutorial/stdlib.po

Lines changed: 136 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ msgstr ""
1212
"Project-Id-Version: Python 3.14\n"
1313
"Report-Msgid-Bugs-To: \n"
1414
"POT-Creation-Date: 2026-07-25 12:59+0330\n"
15-
"PO-Revision-Date: 2021-06-28 01:50+0000\n"
15+
"PO-Revision-Date: 2026-07-31 13:23+0330\n"
1616
"Last-Translator: Alireza Shabani (Revisto) <theRevisto@gmail.com>, 2025\n"
1717
"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/"
1818
"fa/)\n"
@@ -21,6 +21,7 @@ msgstr ""
2121
"Content-Type: text/plain; charset=UTF-8\n"
2222
"Content-Transfer-Encoding: 8bit\n"
2323
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
24+
"X-Generator: Poedit 3.6\n"
2425

2526
#: ../../tutorial/stdlib.rst:5
2627
msgid "Brief tour of the standard library"
@@ -45,6 +46,12 @@ msgid ""
4546
">>> os.system('mkdir today') # Run the command mkdir in the system shell\n"
4647
"0"
4748
msgstr ""
49+
">>> import os\n"
50+
">>> os.getcwd() # Return the current working directory\n"
51+
"'C:\\\\Python314'\n"
52+
">>> os.chdir('/server/accesslogs') # Change current working directory\n"
53+
">>> os.system('mkdir today') # Run the command mkdir in the system shell\n"
54+
"0"
4855

4956
#: ../../tutorial/stdlib.rst:23
5057
msgid ""
@@ -67,6 +74,11 @@ msgid ""
6774
">>> help(os)\n"
6875
"<returns an extensive manual page created from the module's docstrings>"
6976
msgstr ""
77+
">>> import os\n"
78+
">>> dir(os)\n"
79+
"<returns a list of all module functions>\n"
80+
">>> help(os)\n"
81+
"<returns an extensive manual page created from the module's docstrings>"
7082

7183
#: ../../tutorial/stdlib.rst:38
7284
msgid ""
@@ -82,6 +94,11 @@ msgid ""
8294
">>> shutil.move('/build/executables', 'installdir')\n"
8395
"'installdir'"
8496
msgstr ""
97+
">>> import shutil\n"
98+
">>> shutil.copyfile('data.db', 'archive.db')\n"
99+
"'archive.db'\n"
100+
">>> shutil.move('/build/executables', 'installdir')\n"
101+
"'installdir'"
85102

86103
#: ../../tutorial/stdlib.rst:51
87104
msgid "File wildcards"
@@ -99,6 +116,9 @@ msgid ""
99116
">>> glob.glob('*.py')\n"
100117
"['primes.py', 'random.py', 'quote.py']"
101118
msgstr ""
119+
">>> import glob\n"
120+
">>> glob.glob('*.py')\n"
121+
"['primes.py', 'random.py', 'quote.py']"
102122

103123
#: ../../tutorial/stdlib.rst:64
104124
msgid "Command-line arguments"
@@ -117,6 +137,9 @@ msgid ""
117137
"import sys\n"
118138
"print(sys.argv)"
119139
msgstr ""
140+
"# File demo.py\n"
141+
"import sys\n"
142+
"print(sys.argv)"
120143

121144
#: ../../tutorial/stdlib.rst:74
122145
msgid ""
@@ -126,7 +149,7 @@ msgstr ""
126149

127150
#: ../../tutorial/stdlib.rst:77
128151
msgid "['demo.py', 'one', 'two', 'three']"
129-
msgstr ""
152+
msgstr "['demo.py', 'one', 'two', 'three']"
130153

131154
#: ../../tutorial/stdlib.rst:79
132155
msgid ""
@@ -147,6 +170,15 @@ msgid ""
147170
"args = parser.parse_args()\n"
148171
"print(args)"
149172
msgstr ""
173+
"import argparse\n"
174+
"\n"
175+
"parser = argparse.ArgumentParser(\n"
176+
" prog='top',\n"
177+
" description='Show top lines from each file')\n"
178+
"parser.add_argument('filenames', nargs='+')\n"
179+
"parser.add_argument('-l', '--lines', type=int, default=10)\n"
180+
"args = parser.parse_args()\n"
181+
"print(args)"
150182

151183
#: ../../tutorial/stdlib.rst:93
152184
msgid ""
@@ -171,6 +203,8 @@ msgid ""
171203
">>> sys.stderr.write('Warning, log file not found starting a new one\\n')\n"
172204
"Warning, log file not found starting a new one"
173205
msgstr ""
206+
">>> sys.stderr.write('Warning, log file not found starting a new one\\n')\n"
207+
"Warning, log file not found starting a new one"
174208

175209
#: ../../tutorial/stdlib.rst:110
176210
msgid "The most direct way to terminate a script is to use ``sys.exit()``."
@@ -195,6 +229,11 @@ msgid ""
195229
">>> re.sub(r'(\\b[a-z]+) \\1', r'\\1', 'cat in the the hat')\n"
196230
"'cat in the hat'"
197231
msgstr ""
232+
">>> import re\n"
233+
">>> re.findall(r'\\bf[a-z]*', 'which foot or hand fell fastest')\n"
234+
"['foot', 'fell', 'fastest']\n"
235+
">>> re.sub(r'(\\b[a-z]+) \\1', r'\\1', 'cat in the the hat')\n"
236+
"'cat in the hat'"
198237

199238
#: ../../tutorial/stdlib.rst:128
200239
msgid ""
@@ -207,6 +246,8 @@ msgid ""
207246
">>> 'tea for too'.replace('too', 'two')\n"
208247
"'tea for two'"
209248
msgstr ""
249+
">>> 'tea for too'.replace('too', 'two')\n"
250+
"'tea for two'"
210251

211252
#: ../../tutorial/stdlib.rst:138
212253
msgid "Mathematics"
@@ -226,6 +267,11 @@ msgid ""
226267
">>> math.log(1024, 2)\n"
227268
"10.0"
228269
msgstr ""
270+
">>> import math\n"
271+
">>> math.cos(math.pi / 4)\n"
272+
"0.70710678118654757\n"
273+
">>> math.log(1024, 2)\n"
274+
"10.0"
229275

230276
#: ../../tutorial/stdlib.rst:149
231277
msgid "The :mod:`random` module provides tools for making random selections::"
@@ -243,6 +289,15 @@ msgid ""
243289
">>> random.randrange(6) # random integer chosen from range(6)\n"
244290
"4"
245291
msgstr ""
292+
">>> import random\n"
293+
">>> random.choice(['apple', 'pear', 'banana'])\n"
294+
"'apple'\n"
295+
">>> random.sample(range(100), 10) # sampling without replacement\n"
296+
"[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]\n"
297+
">>> random.random() # random float from the interval [0.0, 1.0)\n"
298+
"0.17970987693706186\n"
299+
">>> random.randrange(6) # random integer chosen from range(6)\n"
300+
"4"
246301

247302
#: ../../tutorial/stdlib.rst:161
248303
msgid ""
@@ -261,6 +316,14 @@ msgid ""
261316
">>> statistics.variance(data)\n"
262317
"1.3720238095238095"
263318
msgstr ""
319+
">>> import statistics\n"
320+
">>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]\n"
321+
">>> statistics.mean(data)\n"
322+
"1.6071428571428572\n"
323+
">>> statistics.median(data)\n"
324+
"1.25\n"
325+
">>> statistics.variance(data)\n"
326+
"1.3720238095238095"
264327

265328
#: ../../tutorial/stdlib.rst:173
266329
msgid ""
@@ -270,7 +333,7 @@ msgstr ""
270333

271334
#: ../../tutorial/stdlib.rst:179
272335
msgid "Internet access"
273-
msgstr ""
336+
msgstr "دسترسی به اینترنت"
274337

275338
#: ../../tutorial/stdlib.rst:181
276339
msgid ""
@@ -300,6 +363,24 @@ msgid ""
300363
"... \"\"\")\n"
301364
">>> server.quit()"
302365
msgstr ""
366+
">>> from urllib.request import urlopen\n"
367+
">>> with urlopen('https://docs.python.org/3/') as response:\n"
368+
"... for line in response:\n"
369+
"... line = line.decode() # Convert bytes to a str\n"
370+
"... if 'updated' in line:\n"
371+
"... print(line.rstrip()) # Remove trailing newline\n"
372+
"...\n"
373+
" Last updated on Nov 11, 2025 (20:11 UTC).\n"
374+
"\n"
375+
">>> import smtplib\n"
376+
">>> server = smtplib.SMTP('localhost')\n"
377+
">>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',\n"
378+
"... \"\"\"To: jcaesar@example.org\n"
379+
"... From: soothsayer@example.org\n"
380+
"...\n"
381+
"... Beware the Ides of March.\n"
382+
"... \"\"\")\n"
383+
">>> server.quit()"
303384

304385
#: ../../tutorial/stdlib.rst:204
305386
msgid "(Note that the second example needs a mailserver running on localhost.)"
@@ -334,6 +415,19 @@ msgid ""
334415
">>> age.days\n"
335416
"14368"
336417
msgstr ""
418+
">>> # dates are easily constructed and formatted\n"
419+
">>> import datetime as dt\n"
420+
">>> now = dt.date.today()\n"
421+
">>> now\n"
422+
"datetime.date(2003, 12, 2)\n"
423+
">>> now.strftime(\"%m-%d-%y. %d %b %Y is a %A on the %d day of %B.\")\n"
424+
"'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'\n"
425+
"\n"
426+
">>> # dates support calendar arithmetic\n"
427+
">>> birthday = dt.date(1964, 7, 31)\n"
428+
">>> age = now - birthday\n"
429+
">>> age.days\n"
430+
"14368"
337431

338432
#: ../../tutorial/stdlib.rst:236
339433
msgid "Data compression"
@@ -361,6 +455,17 @@ msgid ""
361455
">>> zlib.crc32(s)\n"
362456
"226805979"
363457
msgstr ""
458+
">>> import zlib\n"
459+
">>> s = b'witch which has which witches wrist watch'\n"
460+
">>> len(s)\n"
461+
"41\n"
462+
">>> t = zlib.compress(s)\n"
463+
">>> len(t)\n"
464+
"37\n"
465+
">>> zlib.decompress(t)\n"
466+
"b'witch which has which witches wrist watch'\n"
467+
">>> zlib.crc32(s)\n"
468+
"226805979"
364469

365470
#: ../../tutorial/stdlib.rst:258
366471
msgid "Performance measurement"
@@ -389,6 +494,11 @@ msgid ""
389494
">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n"
390495
"0.54962537085770791"
391496
msgstr ""
497+
">>> from timeit import Timer\n"
498+
">>> Timer('t=a; a=b; b=t', 'a=1; b=2').timeit()\n"
499+
"0.57535828626024577\n"
500+
">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n"
501+
"0.54962537085770791"
392502

393503
#: ../../tutorial/stdlib.rst:274
394504
msgid ""
@@ -431,6 +541,16 @@ msgid ""
431541
"import doctest\n"
432542
"doctest.testmod() # automatically validate the embedded tests"
433543
msgstr ""
544+
"def average(values):\n"
545+
" \"\"\"Computes the arithmetic mean of a list of numbers.\n"
546+
"\n"
547+
" >>> print(average([20, 30, 70]))\n"
548+
" 40.0\n"
549+
" \"\"\"\n"
550+
" return sum(values) / len(values)\n"
551+
"\n"
552+
"import doctest\n"
553+
"doctest.testmod() # automatically validate the embedded tests"
434554

435555
#: ../../tutorial/stdlib.rst:306
436556
msgid ""
@@ -455,6 +575,19 @@ msgid ""
455575
"\n"
456576
"unittest.main() # Calling from the command line invokes all tests"
457577
msgstr ""
578+
"import unittest\n"
579+
"\n"
580+
"class TestStatisticalFunctions(unittest.TestCase):\n"
581+
"\n"
582+
" def test_average(self):\n"
583+
" self.assertEqual(average([20, 30, 70]), 40.0)\n"
584+
" self.assertEqual(round(average([1, 5, 7]), 1), 4.3)\n"
585+
" with self.assertRaises(ZeroDivisionError):\n"
586+
" average([])\n"
587+
" with self.assertRaises(TypeError):\n"
588+
" average(20, 30, 70)\n"
589+
"\n"
590+
"unittest.main() # Calling from the command line invokes all tests"
458591

459592
#: ../../tutorial/stdlib.rst:328
460593
msgid "Batteries included"

0 commit comments

Comments
 (0)