Localisation

111 views
Skip to first unread message

Oleksa Stasevych

unread,
Jan 23, 2021, 8:24:15 PM1/23/21
to Helios Voting
Hi!

I would like to add Ukrainian localisation and the switcher between languages. Please, explain, how to do that (python3)?

Thanks!

BR, Oleksa

Ben Adida

unread,
Jan 23, 2021, 8:42:54 PM1/23/21
to Helios Voting

Hi Oleksa,

Unfortunately, Helios is not set up for localization. This is something I hope we can get to after the many upgrades ongoing (python3, django, etc.)

-Ben

--
--
Helios Voting Google Group
To post: helios...@googlegroups.com
To unsubscribe: helios-votin...@googlegroups.com
More: http://groups.google.com/group/helios-voting?hl=en

---
You received this message because you are subscribed to the Google Groups "Helios Voting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to helios-votin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/helios-voting/13a96b09-2e1c-41d3-bf78-beb3f43499efn%40googlegroups.com.

Oleksa Stasevych

unread,
Jan 24, 2021, 4:50:11 AM1/24/21
to Helios Voting
Hi Ben!

Thanks for your comments. I saw that Zeus, and IFSC somehow managed to add localisation. I was trying to play with LANGUAGES by adding locale and LC_MESSAGES, though without much success. Perhaps, you may lead me somewhere?

What I would like to do is to localise the UI and the templates.

Thank you!

With kind regards
Oleksa

Ben Adida

unread,
Jan 24, 2021, 9:05:40 PM1/24/21
to Helios Voting

Oleksa,

It's not going to be simple, there are client-side and server-side issues to handle. I'm always open to PRs and input, but I think this one will require a good bit of foundational work.

-Ben

Warwick McNaughton

unread,
Jan 28, 2021, 6:11:48 PM1/28/21
to helios...@googlegroups.com
Hi Oleksa

Just to note that Belenios has localisation and specifically Ukrainian: 


Ukrainian language localisation submitted by Andrii Shachykov:

 It is based on Helios but it is not written in python - it is written in OCaml. 

Thought I would point it out, but it might be a steep learning curve.   With some effort I managed to put it in a Docker container for deployment on Heroku just for testing purposes:

Regards

Warwick


Oleksa Stasevych

unread,
Jan 28, 2021, 6:32:22 PM1/28/21
to Helios Voting
Hi Warwick!

Many thanks for your quick reply. Actually, I am trying to work with your heroku instance and even created an app using your branch for heroku. Now I am trying to understand how that works :)

What I found that in the templates there's already mentioned locale code. Perhaps, it is possible to create templates in different languages and add some switcher somewhere?.. As a quick and dirty solution? 

Also, I know that Zeus and Shirley (https://github.com/shirlei/helios-server) managed to achieve that somehow. 

BR, Oleksa

Warwick McNaughton

unread,
Jan 28, 2021, 6:36:10 PM1/28/21
to helios...@googlegroups.com
Helios is based on the Django framework which provides for localisation.  This might be a good starting point:


Oleksa Stasevych

unread,
Jan 28, 2021, 7:34:21 PM1/28/21
to Helios Voting
Thank you! It is a great input.
I have another question regarding the users, who may create election. I am trying to restrict only to certain persons. For that I changed HELIOS_ADMIN_ONLY=True, added emails and names to the variable ADMINS. However, anybody now may create election. 
Would you be so kind to help me to understand, how to make this restriction in a correct way?

Thanks!

BR, Oleksa

Jean Martina

unread,
Jan 29, 2021, 4:06:24 AM1/29/21
to helios...@googlegroups.com

Things are not that straight forward. Some of the things on Helios like the booth and the text on emails are not not django translatable. Some are meant to run on the client machine or they are just a django templates which has a sketchy way for internationalization.

I have been working and contributing to Shirlei's fork, and although you can generate a .po file for doing the translation this only helps with the Django part.

My tip here would be to use her fork because it already has the i18n annotation on messages, and write your own language .po file. Then you need to rewrite the booth and the emails manually. This is much easier than staring from

Maybe internationalization is a good feature to work on after the big migration python 3 finishes. Having them by default on Ben's repository would help a lot of people.

Jean

Oleksa Stasevych

unread,
Jan 29, 2021, 4:23:38 PM1/29/21
to Helios Voting
Hi! Ah, I prefer to use python3 and actually I haven't managed to deploy shirley's fork on my own home server and dropped this idea, plus, there are a lot of other unnecessary for me staff eg LDAP, which I decided not to touch.

I tried to add to settings.py 

...
import os, json
from django.utils.translation import ugettext_lazy as _
...
LANGUAGES = (('uk-ua', _('Ukrainian')),)
LOCALE_PATHS = (ROOT_PATH + '/locale',)
USE_L10N=True

...

What else should be done? Perhaps, you may guide me?

BR, Oleksa

Jean Martina

unread,
Jan 31, 2021, 4:27:39 AM1/31/21
to helios...@googlegroups.com

Hi Oleska,

    I believe that bringing localization support for Ben's repo will be the final answer to that. I can help you to do that once phyton3 is the default and we know that we will be able to PR the change in there.

    Taking on what you mentioned, I think it is important to do some revamp on the authentication modules part. Some problems in there is the lack of maintenance or documentation in some default modules (CAS for example),  as well as the inability to mix and match auth modules, thus making elections fixed on a specific identity provider. Another issue regards not being able to stack authentications (for example, LDAP + password, or Digital Certificates + LDAP + Password). We had this requirement in the past, and had to do a workaround to make it happen. Definitely not beautiful, but functional.

    We have been conducting many (100+) elections with helios, some being very big use cases. We did twice a 142k voters and once a 38k voter. We have now for March 2021 another one for 43k voters. They usually run with some of our customization because Helios on phyton2 has a performance ceiling even when run on bare metal. So we are very excited to see it moving to python3, what may easy a bit that.

    Regarding Shirlei's modules, they are very useful when you use Helios as an institution-wide solution (LDAP) or in a multi-institution (Shibboleth) scenario. We also developed a digital certificate module (which is PRed on Shirlei's repo) and an Ethereum Smart-Contract patch that helps with keeping track on the configuration and publicizing the Bulletin-Board (not casting votes because this is the Achilles heel of blockchain voting). These were used on some of our specific elections, but can be made available to the community.


Regards,


Jean

Oleksa Stasevych

unread,
Jan 31, 2021, 11:19:50 AM1/31/21
to Helios Voting
Dear Jean!

Oh, so a lot done. Thank you for clarifications. Yesterday I was studying django localisation and managed to get first results on python3 by reusing shirley's version, in particular I've added the language switcher and localised the menu items. Later I plan to localise the UI and mail notifications.

I am waiting for the update from Ben on python3, as warwick's version has some bugs. And will be ready to share with you results.
In 2 weeks our non-profit organisation is holding the voting for the Statutory board and exactly due to that I have started to study existing solutions. Will be ready to share with you my localisation attempts.

BR,  Oleksa

Oleksa Stasevych

unread,
Feb 1, 2021, 9:15:13 AM2/1/21
to Helios Voting
Hi all! Did you have successes to localise the heliosbooth part? I faced with the challenge, that it is completely Javascript based and cannot find the way to read the strings from the localisation files. In the shirley's repo this part is not localised but completely replaced with the Portuguese.

Thanks!

BR, Oleksa

Jean Martina

unread,
Feb 1, 2021, 12:48:23 PM2/1/21
to helios...@googlegroups.com
Dear Oleska,

Em 01/02/2021 15:15, Oleksa Stasevych escreveu:
> I faced with the challenge, that it is completely Javascript based and
> cannot find the way to read the strings from the localisation files.

That's what I wanted to point out in here:

"Things are not that straight forward. Some of the things on Helios like
the booth and the text on emails are not not django translatable. Some
are meant to run on the client machine or they are just a django
templates which has a sketchy way for internationalization."

But a dummy solution for that is having i18n directories for each
language. For example Shirlei's pt-BR could be moved one directory below
a directory called pt-BR and yours could be on uk-UA. Then whenever you
configure Helios in a localized way it will find things there.

If this is to be worked out as a new feature for Helios it would be nice
to hear from others if we are going the right direction.

Regards,

Jean

Oleksa Stasevych

unread,
Feb 1, 2021, 3:55:30 PM2/1/21
to Helios Voting
Dear Jean,

On Monday, 1 February 2021 at 19:48:23 UTC+2 jean.m...@gmail.com wrote:
Dear Oleska,

Em 01/02/2021 15:15, Oleksa Stasevych escreveu:
> I faced with the challenge, that it is completely Javascript based and
> cannot find the way to read the strings from the localisation files.

That's what I wanted to point out in here: 


"Things are not that straight forward. Some of the things on Helios like
the booth and the text on emails are not not django translatable. Some
are meant to run on the client machine or they are just a django
templates which has a sketchy way for internationalization."
 
I've studied the manual and there is a solution, however I do not understand, why it is not so working here, in particular:
...
Using the JavaScript translation catalog

To use the catalog, just pull in the dynamically generated script like this:

<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>

This uses reverse URL lookup to find the URL of the JavaScript catalog view. When the catalog is loaded, your JavaScript code can use the following methods:

  • gettext
  • ngettext
  • interpolate
  • get_format
  • gettext_noop
  • pgettext
  • npgettext
  • pluralidx
gettext

The gettext function behaves similarly to the standard gettext interface within your Python code:

document.write(gettext('this is to be translated')); 
....

What I see that python variables are not accepted by heliosbooth, in particular by the file /heliothbooth/vote.html.
In the <head> section I added <script type="text/javascript" src="/jsi18n/"></script>

I tested with replacing the title of the booth
<div id="banner"><script>document.write(gettext('Helios Voting Booth'));</script></div>

Parsing the variables with django-admin makemessages -d djangojs doesn't show that the new ones to be appeared in djangojs.po.

And yes, the localisation strings are stored in locale/uk_UA/LC_MESSAGES: django.po, djangojs.po and the compiled versions django.mo, djangojs.mo.
I have a proper LOCALE_PATHS setting in the settings.py. It works fine with server_ui/templates, helios/templates, but not with the heliosbooth

Perhaps I am missing something here? Sorry, I am very nube here.


But a dummy solution for that is having i18n directories for each
language. For example Shirlei's pt-BR could be moved one directory below
a directory called pt-BR and yours could be on uk-UA. Then whenever you
configure Helios in a localized way it will find things there.

Shirley made a dirty hardcode of the translation in the files in heliosbooth, what is not good for me, as I would like to have at least 2 languages (English and Ukrainian).


If this is to be worked out as a new feature for Helios it would be nice
to hear from others if we are going the right direction.

BR, Oleksa 

Jean Martina

unread,
Feb 2, 2021, 3:32:52 AM2/2/21
to helios...@googlegroups.com

Oleska,

    If you have a fork where I can join and help you I would be glad to do so. My github account is jeanmartina

    Regarding your issue, did you import django.views.i18n and changed accordingly urlpatterns in urls.py?

    To me a reason for django-admin makemessages -d djangojs not working is because django is not seeing you import anywhere the i18n for JavaScriptCatalog

    Take a look here: https://docs.djangoproject.com/en/2.2/topics/i18n/translation/#module-django.views.i18n

Regards,

Jean

--
--
Helios Voting Google Group
To post: helios...@googlegroups.com
To unsubscribe: helios-votin...@googlegroups.com
More: http://groups.google.com/group/helios-voting?hl=en

---
You received this message because you are subscribed to the Google Groups "Helios Voting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to helios-votin...@googlegroups.com.

Oleksa Stasevych

unread,
Feb 2, 2021, 5:54:38 AM2/2/21
to Helios Voting
Hi Jean, Ben!

Jean, thank you for your kind readiness to help me to deal with it and your recommendations. No I am self-studying and self-developing on a heroku server by changing warwick's version. In this mailing list I found that Ben is also testing his python3 version, which has some bugs already solved. I would like to fork it or join its development (doesn't know yet) in order not to bring much more mess. 

Ben, may I ask you to share the link to your repo with helios-server python3 version if it is already available for forking?

BR, Oleksa

Jean Martina

unread,
Feb 2, 2021, 6:10:53 AM2/2/21
to helios...@googlegroups.com
I seen Ben's Repo this morning and it seems there is a branch there
called "bens-cleaned-up-py3" that has very recent commits.

Maybe you can fork Ben's repo and branch from that branch.


Jean

Shirlei Chaves

unread,
Feb 2, 2021, 7:52:02 AM2/2/21
to Helios Voting
Oleska, I really understand your frustration, but I think you are missing the point here.
As Jean kindly pointed out, things are not that straight forward.
When you try to use Django's javascript translation tool in heliothbooth/vote.html you are trying to add a django tool to a file that is not 'served' by  Django.
Django's tools for translation are only applicable for code that is actually served by the application server.
All other files are static, served by the web server.
This is why, as I explained in other situations, I've just added django translation tools where applicable and in the static part I did exactly what you called 'dirty hardcoded' translation.
That suited well for the project and time I had in hand, as well has helped to popularise helios tool in my country.
However, if you take the time to carefully read this group, you'll will find out that this problem (django's tools not broadly applicable/ applying maybe a pure js solution for all the code to be parsed in the client, for example) has already been discussed several times.


Maybe you can start from there, bringing your contribution to this issue, that as mentioned by Ben in the thread I cited above, takes a significant effort and is one of the Helios weakeness, as agreed by Ben in yet another thread.

Good luck with your project!

All the best !

Oleksa Stasevych

unread,
Feb 2, 2021, 9:01:50 AM2/2/21
to Helios Voting
Thank you, Jean!

Oleksa Stasevych

unread,
Feb 2, 2021, 9:04:30 AM2/2/21
to Helios Voting
Dear Shirley!

Thank you for pointing my attention. I have not passed through all messages, however came to the same understanding recently. Sorry, I have to go deeper in the mailing list to find the answers and thanks for providing example.

I will try to cope with that, though in face this is my first attempt to work with the django apps, to be honest.

BR, Oleksa

Oleksa Stasevych

unread,
Feb 4, 2021, 5:14:39 PM2/4/21
to Helios Voting
Hi Jean,

I tried this repo, and it is not python3 sadly... Moreover, I didn't manage to deploy it on heroku.

On Tuesday, 2 February 2021 at 13:10:53 UTC+2 jean.m...@gmail.com wrote:

Oleksa Stasevych

unread,
Feb 7, 2021, 11:31:12 PM2/7/21
to Helios Voting
Hi all! Let me share first successes. I have managed to localise the major parts of the system and even heliosbooth (with certain limitations). The process is still ongoing. I have also added very simple language switcher. I used the last version of Ben Adido https://github.com/benadida/helios-server/tree/bens-cleaned-up-py3.

With heliosbooth and other javascript static files I applied dirty hack by adding <script language="javascript" src="/jsi18n/"></script> and proper gettext constructions inside of the html code. Sometimes they look not so nice, and I haven't yet evaluated the load. Let me add, that makemessage is not working, and I produced the .po files manually.

I haven't find the way how to pass the selected language to heliosbooth from the main application, however, I found that the language is taken from the current session more or less correctly (if any), but is not working completely for the new users, authenticating from the links in received invitation emails.

This is what I observe in the code, which is automatically changing dependently of the locale:
<script language="javascript" src="/uk-ua/jsi18n/"></script>
<script language="javascript" src="/en-us/jsi18n/"></script> 

I see that the  It works now somehow, but not comfortable.

I have placed the copy of Heroku repo in github, and will be very appreciative for any further help with it https://github.com/ostasevych/helios-server-ostasevych-heroku-py3-localised

PS This is my first github, django and even python experience, so, please, be not so critical :)
 
PPS Additionally, I would like to work with the screen adaptivity: the sandwich button exists, but is not working... This is crucial for working from mobile phones. 

Oleksa Stasevych

unread,
Feb 16, 2021, 1:19:51 PM2/16/21
to Helios Voting
Hi! I faced with another challenge, which cannot overcome. When a user changes language, the url is appended with the language code, eg. uk-ua. 
The cast_url is fixed, and when elections were created by an admin who selected English, and the user selects Ukrainian, I am getting an error when clicking Submit button.
I don't know how to overcome this issue, honestly talking :(

BR, Oleksa

Tom Thomas

unread,
Feb 16, 2021, 2:07:03 PM2/16/21
to helios...@googlegroups.com
Simplest way to fix this is to update the cast_url directly in the DB or through a minor code change that forces it.

--
--
Helios Voting Google Group
To post: helios...@googlegroups.com
To unsubscribe: helios-votin...@googlegroups.com
More: http://groups.google.com/group/helios-voting?hl=en

---
You received this message because you are subscribed to the Google Groups "Helios Voting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to helios-votin...@googlegroups.com.

Oleksa Stasevych

unread,
Feb 17, 2021, 2:57:44 PM2/17/21
to Helios Voting
Hi! Thanks for your comment.

Finally I did that through some dirty hack: in the seal.html I changed {cast_url} to {gettext('/current_locale')}helios/elections/{$T.election_uuid}/cast
And I added /current_locale/ message string to djangojs.po with the proper language codes.

However, this is partial solution. I need to fix the election_vote_url as well in the email templates, eg vote_body.txt and others in order NOT to allow a voter to come to the wrong url (which contains the language code). This appears, if a manager sends a letter of invitation and selected not English locale. Let me add that English is the default language, plus there's definition prefix_default_language = False in urls.py.

I tried to use the same hack by adding {{ settings.SECURE_URL_HOST }} /helios/{{election.short_name}}/vote to the mail templates, but that didn't work :( I found that any variable from the settings.py file is not simply shown in the template. Perhaps you may suggest something as well? 

BR, Oleksa

Jean Martina

unread,
Feb 19, 2021, 6:15:19 AM2/19/21
to helios...@googlegroups.com

Hi Oleska,

    Can you share the link for your repo? I am interested in taking a look on your effort for internationalization. In the next week I will have sometime to help on that.


Jean

Oleksa Stasevych

unread,
Feb 19, 2021, 6:35:01 AM2/19/21
to Helios Voting
Hi Jean!

I have shared it earlier, however there were no changes in github repo, as I am mostly working with internal Heroku local repo. 
This weekend we will have a big election using this system (around 100 members). 

After that I will resync the repo with github. I may need some help to understand how to operate with different branches (prod, test and dev) in order not to break the prod one.

BR, Oleksa

Oleksa Stasevych

unread,
Feb 25, 2021, 6:05:03 PM2/25/21
to Helios Voting
Dear Jean, 

I have updated my repo with the last version, which you may find over here https://github.com/ostasevych/helios-server-ostasevych-heroku-py3-localised/
Let me add that I have several unsolved things:
- in the mail templated I didn't manage to find the way to use the global settings.XXXX variables
- in the localisation files I hardcoded the locale
- bug: on the page with elections the exact time of the election expiration is not shown, and when extending the elections both the date and the time are not shown

BR, Oleksa

On Friday, 19 February 2021 at 13:15:19 UTC+2 jean.m...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages