-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean Emergency page translations #2048
Comments
The IFRCGo/go-web-app#627 analysis can be done only before the action of this ticket, so this should be executed, only when #627 is done. |
Hey @szabozoltan69 . Here is a draft PR to run manual translation. Let me know if any additional information is required. |
Some clarification and usage hints would be highly appreciated. |
Could you give some hints @thenav56 how to continue this task? |
Hey @szabozoltan69, I hope this helps. Here is the pseudo code we will need for this: from lang.tasks import ModelTranslator
from main.translation import TRANSLATOR_SKIP_FIELD_NAME, TRANSLATOR_ORIGINAL_LANGUAGE_FIELD_NAME
from api.models import Event
def en_to_fr():
pks = [...] # List of primary keys -- Or read the content from an xlsx file instead?
events = Event.objects.filter(
pk__in=pks,
**{TRANSLATOR_SKIP_FIELD_NAME: False},
)
print('Translating EN->FR')
for event in events:
assert getattr(event, TRANSLATOR_ORIGINAL_LANGUAGE_FIELD_NAME) == 'en'
# TODO: Should we read the content from an xlsx file instead?
event.name_fr = event.name_en
event.summary_fr = event.summary_en
...
# Clear the original English fields - Auto translator will only fill empty fields
event.name_en = ''
event.summary_en = ''
...
# Change the original language to French
setattr(event, TRANSLATOR_ORIGINAL_LANGUAGE_FIELD_NAME, 'fr')
# Save the new state (Use update_fields= if required)
event.save()
# Translate fields dynamically and save the object
ModelTranslator().translate_model_fields(event)
print('- Translated successfully:', event.pk)
en_to_fr()
en_to_es()
es_to_en() This code will translate event fields from English to French and save the changes. Similar functions can be created for other language translations. |
I check visually the in-xlsx id-s and the newly found ones (without HTML tags) via:
– the French ones | and the Spanish ones –
Also those ones which are not translated at all and which are presumably in English (which are on the 3rd tab in xlsx):
|
Task done, some unsuccessful ones from scope 3 are below, they are fixed manually via simplifying the rich text HTML code. At 6559 the autotranslation had to be switched off, otherwise the table translations could not be done.
|
I could use the above pseudocode fine, with a small change, allowing to continue the loop in case of error also: # Translate fields dynamically and save the object
try:
ModelTranslator().translate_model_fields(event)
print('- Translated successfully:', event.pk)
except:
print('Unsuccessful:', event.pk) |
We would like to clean the emergencies languages and provide dynamic translations for the historic data.
The attached xlsx lists those emergency IDs that needs some batch action.
Actions to be done per worksheet:
Emerg (UI- En, summ. - Fr) - copy
Summary [en]
,Title [en]
fields content tosummary [fr]
andTitle [fr]
, then change theEntity original language
to French. Initiate translation. - 40 itemsEmerg (UI- En, summ.- Es) - copy Summary [en], Title [en] fields content to summary [es] and Title [es], then change the Entity original language to Spanish. Initiate translation. - 104 items
Emerg (UI- Es, summ.- En) - Initiate translation. - 424 items
Summary_emergencies-to_be_translated-v3.xlsx
The text was updated successfully, but these errors were encountered: