|
11 | 11 | Usage: |
12 | 12 | pip install -e .[localize] |
13 | 13 | doit list # see available tasks |
| 14 | +doit localize # runs all localization tasks in sequence: properties -> po -> mo |
14 | 15 |
|
15 | 16 | """ |
16 | 17 |
|
17 | 18 |
|
| 19 | +def task_localize(): |
| 20 | + """ |
| 21 | + Runs localization pipeline in sequence: |
| 22 | + properties -> po -> mo |
| 23 | + """ |
| 24 | + return { |
| 25 | + "actions": [], |
| 26 | + "task_dep": ["properties", "po", "mo"], |
| 27 | + } |
| 28 | + |
| 29 | + |
18 | 30 | def task_properties(): |
19 | 31 |
|
20 | 32 | """ |
@@ -252,48 +264,6 @@ def process_locales(): |
252 | 264 | } |
253 | 265 |
|
254 | 266 |
|
255 | | -def task_clean_all(): |
256 | | - |
257 | | - """remove all generated files such as .po, .out, and pdf, csv etc that are not in the assets folder""" |
258 | | - |
259 | | - def clean_output_files(): |
260 | | - print("todo - delete pdf, csv, .twbx, .hyper etc that have been produced in tests") |
261 | | - |
262 | | - """For all languages: removes all generated intermediate files (properties, po) from the loc build. |
263 | | - all we need to keep are the provided translation.properties files from the monolith, at locales/[current_locale] |
264 | | - and the final tabcmd.mo files in LC_MESSAGES generated by |
265 | | - >doit properties po mo |
266 | | - """ |
267 | | - |
268 | | - def clean_string_files(): |
269 | | - for current_locale in LOCALES: |
270 | | - FILESETS = [ |
271 | | - os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.properties"), |
272 | | - os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.po"), |
273 | | - os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.out"), |
274 | | - ] |
275 | | - for PATH in FILESETS: |
276 | | - for file in glob.glob(PATH): |
277 | | - print("deleting {}".format(os.path.abspath(file))) |
278 | | - try: |
279 | | - os.remove(file) |
280 | | - except OSError: |
281 | | - pass |
282 | | - |
283 | | - STRING_FILES = os.path.join("tabcmd", "locales", "codestrings.*") |
284 | | - for file in glob.glob(STRING_FILES): |
285 | | - print("deleting {}".format(os.path.abspath(file))) |
286 | | - try: |
287 | | - os.remove(file) |
288 | | - except OSError: |
289 | | - pass |
290 | | - |
291 | | - return { |
292 | | - "actions": [clean_string_files, clean_output_files], |
293 | | - "verbosity": 2, |
294 | | - } |
295 | | - |
296 | | - |
297 | 267 | def task_mo(): |
298 | 268 | """ |
299 | 269 | For all languages: Processes the tabcmd.po file to produce a final tabcmd.mo file for each language |
@@ -418,3 +388,45 @@ def uniquify_file(filename): |
418 | 388 | ) |
419 | 389 | else: |
420 | 390 | print("Saved {} sorted unique lines to {}".format(len(uniques), filename)) |
| 391 | + |
| 392 | + |
| 393 | +def task_clean_all(): |
| 394 | + |
| 395 | + """remove all generated files such as .po, .out, and pdf, csv etc that are not in the assets folder""" |
| 396 | + |
| 397 | + def clean_output_files(): |
| 398 | + print("todo - delete pdf, csv, .twbx, .hyper etc that have been produced in tests") |
| 399 | + |
| 400 | + """For all languages: removes all generated intermediate files (properties, po) from the loc build. |
| 401 | + all we need to keep are the provided translation.properties files from the monolith, at locales/[current_locale] |
| 402 | + and the final tabcmd.mo files in LC_MESSAGES generated by |
| 403 | + >doit properties po mo |
| 404 | + """ |
| 405 | + |
| 406 | + def clean_string_files(): |
| 407 | + for current_locale in LOCALES: |
| 408 | + FILESETS = [ |
| 409 | + os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.properties"), |
| 410 | + os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.po"), |
| 411 | + os.path.join("tabcmd", "locales", current_locale, "LC_MESSAGES", "*.out"), |
| 412 | + ] |
| 413 | + for PATH in FILESETS: |
| 414 | + for file in glob.glob(PATH): |
| 415 | + print("deleting {}".format(os.path.abspath(file))) |
| 416 | + try: |
| 417 | + os.remove(file) |
| 418 | + except OSError: |
| 419 | + pass |
| 420 | + |
| 421 | + STRING_FILES = os.path.join("tabcmd", "locales", "codestrings.*") |
| 422 | + for file in glob.glob(STRING_FILES): |
| 423 | + print("deleting {}".format(os.path.abspath(file))) |
| 424 | + try: |
| 425 | + os.remove(file) |
| 426 | + except OSError: |
| 427 | + pass |
| 428 | + |
| 429 | + return { |
| 430 | + "actions": [clean_string_files, clean_output_files], |
| 431 | + "verbosity": 2, |
| 432 | + } |
0 commit comments