question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bench update-translations | fails

See original GitHub issue

So we tried to follow this https://frappeframework.com/docs/user/en/guides/basics/translations#5-bootstrapping-a-new-language

We decided to modify just a few strings, so this is orig.csv

Shared With
Shared with everyone
Shared with {0}
Tags
Attachment
Attachments
Assigned To
Not Saved
Reviews

and then we translated, and this is trans.csv

Shared With,Compartido con,
Shared with everyone,Compartido con todos,
Shared with {0},Compartido con {0},
Tags,Etiquetas,
Attachment,Adjunto,
Attachments,Adjuntos,
Assigned To,Asignado a,
Not Saved,No guardado,
Reviews,Comentarios,

However when I run this command bench update-translations es-UY ~/orig.csv ~/trans.csv this is the output I get. Are we skipping a step, is the guide old?

We just want to translate our app to es-UY with our custom strings

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/operador/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 99, in <module>
    main()
  File "/home/operador/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/operador/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/operador/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 26, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/operador/frappe-bench/apps/frappe/frappe/commands/translate.py", line 68, in update_translations
    frappe.translate.update_translations(lang, untranslated_file, translated_file)
  File "/home/operador/frappe-bench/apps/frappe/frappe/translate.py", line 674, in update_translations
    write_translations_file(app, lang, full_dict)
  File "/home/operador/frappe-bench/apps/frappe/frappe/translate.py", line 708, in write_translations_file
    write_csv_file(os.path.join(tpath, lang + ".csv"),
  File "/home/operador/frappe-bench/apps/frappe/frappe/translate.py", line 598, in write_csv_file
    for p, m in app_messages:
ValueError: too many values to unpack (expected 2)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
i5ocommented, Feb 12, 2021

Well I just realized that context in the csv is no longer used, so

def write_csv_file(path, app_messages, lang_dict):
        """Write translation CSV file.

        :param path: File path, usually `[app]/translations`.
        :param app_messages: Translatable strings for this app.
        :param lang_dict: Full translated dict.
        """
        app_messages.sort(key = lambda x: x[1])
        from csv import writer
        with open(path, 'w', newline='') as msgfile:
                w = writer(msgfile, lineterminator='\n')
                for entry in app_messages:
                        line, original_string = [entry[0], entry[1]]
                        translated_string = lang_dict.get(original_string, '')
                        # strip whitespaces
                        translated_string = re.sub('{\s?([0-9]+)\s?}', "{\g<1>}", translated_string)
                        w.writerow([original_string, translated_string])
                        ```

This still does the job and makes the other 2 commands specified work

0reactions
ikslavokcommented, Feb 14, 2021

Don’t know if this will be relevant for you, but the way I did the translating workflow is this.

  • I got all strings for translation to one myCompany.csv
  • I created another file named myCompanyTranslated.csv pasted all the strings there.
  • Used google sheet with GOOGLETRANSLATE() function to get strings translated. Its awful translation BTW.
  • Then updated strings for that locale with bench comand
  • Added new locale to frappe/frappe/geo/languages.json

I then in my custom app created a bin folder added 2 subfolders for each app translation and created a bash script to copy translations from my GIT managed app to frappe and erpnext apps. So now when I see something that needs translating I do this:

  1. Translate strings
  2. Run the script Now refresh page and translation is live

This is file structure of bin folder 2021-02-14 08 11 24 github com 636b67012899

This Is the Script

#!/bin/bash

cp ~/frappe-bench/apps/myApp/bin/trans_erpnext/myTranslation.csv ~/frappe-bench/apps/erpnext/erpnext/translations/myTranslation.csv
cp ~/frappe-bench/apps/myApp/bin/trans_frappe/myTranslation.csv  ~/frappe-bench/apps/frappe/frappe/translations/myTranslation.csv
bench clear-cache

git add .
git commit -m "I just translated something"
git push
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bench update-translations is broken · Issue #11738 - GitHub
I'm trying to update some translations after using the get-untranslated command, I edit the new file, when It's time to update the translation...
Read more >
Common Errors with Exporting and Importing Translation Files
Troubleshoot issues you can encounter while exporting and importing files in Translation Workbench.
Read more >
Bench Commands - Frappe Framework
download-translations Download latest translations exclude-app Exclude app from updating find Finds benches recursively from location get-app Clone an app from ...
Read more >
Bench download-translations server error - ERPNext Forum
I tried bench download-translations, but the downloaded files are htm pages indic… ... The error persists, any update?
Read more >
Hilarious Examples of Translation Fails in Advertising - Lytho
20 Examples of Funny Translation Fails in Advertising · 1. KFC. China translated “Finger Licking Good” (KFC) into a somewhat cannibalistic message. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found