I have been reading Not Found and have bootstrapped for at new language.
bench frappe --get_untranslated [lang] [path]
However the file is over 5000 lines and seems totally unordered to me.
I have been looking at at the translate.py under frappe-bench/apps/frappe/frappe to possible modify it to accept som kind on delimiter on the export.
def get_untranslated(lang, untranslated_file, get_all=False):
"""translate objects using Google API. Add you own API key for translation"""
clear_cache()
apps = frappe.get_all_apps(True)
messages = []
untranslated = []
for app in apps:
messages.extend(get_messages_for_app(app))
messages = list(set(messages))
def escape_newlines(s):
return (s.replace("\\\n", "|||||")
.replace("\\n", "||||")
.replace("\n", "|||"))
if get_all:
print str(len(messages)) + " messages"
with open(untranslated_file, "w") as f:
for m in messages:
# replace \n with ||| so that internal linebreaks don't get split
f.write((escape_newlines(m) + os.linesep).encode("utf-8"))
else:
full_dict = get_full_dict(lang)
for m in messages:
if not full_dict.get(m):
untranslated.append(m)
if untranslated:
print str(len(untranslated)) + " missing translations of " + str(len(messages))
with open(untranslated_file, "w") as f:
for m in untranslated:
# replace \n with ||| so that internal linebreaks don't get split
f.write((escape_newlines(m) + os.linesep).encode("utf-8"))
else:
print "all translated!"
How can I modify this to accept an extra parameter specifying a specific part of the app?
EDIT: (20150223T1641GMT+1)
instead of exporting everything into a single file - it would be nice if the export created a single file per module
I get that. I am not anyway refererring to the runtime I really don’t care about that section
AFAIU the –update_translation is somewhat agnostic as long as it has the original file to compare against.
The primary goal was having the –get_untranslated function allowing for a more translation friendly environment by creating one file per module.
See - this makes the task more approachable since one can translate smaller portions of the overall interface - instead of getting stuck with the nasty machine translation.
This would make the task much more managable and a lot easier to troubleshoot - hence the stonewalling issue.
@pdvyas @rmehta
I know - even though - the task of translating 5000+ lines, seemingly appearing in random order - that really gets to you.
By the way - the da-DK lang does not exist.
But would it be such a huge change?
current
the function is writing one single file outside the app/module loop
change to
the function write a file inside the module loop (ideally composing the input-filename with the module-name) before shifting to next module
As mentioned - I have no experience in python - also I do not have the deep understanding you have of the –get_untranslated function.
AFAIS the change would be minor - if having the deep knowledge of the python modules.
Obviously I have no such knowledge.
I would have to spend hours searching through your modules to get an idea of how you accomplish this task.
Then I might be able to clash some code but that would not be optimal to accomplish a change that you could implement in what? 30 minutes? because you know exactly where to inject the new code.
We add it to the translator now and you can edit online (but I guess, you want to go module wise)
[version 5] On your local, add the language to frappe/data/languages.txt and run bench frappe --rebuild_translations, this should generate the da-DK.csv with three columns, Position, Source and Translated (would be empty). You can then sort by position on first column in your spreadsheet program, they will appear almost module wise.
Hey, for technical reasons of versioning we can only merge translations via file once. After that, when it hits the translator portal, we cannot merge csv as there’s no way to know if a string was corrected or not. So, you can send a pull request after you’re done with a sizable amount of strings, then we add it translator. Is that fine?