otm translation

155 views
Skip to first unread message

Filipe Marques

unread,
Mar 20, 2015, 2:41:16 PM3/20/15
to opentree...@googlegroups.com
Hey guys, I'm trying to translate the otm to portuguese. So I created a locale folder under the treemap dir and started translating there. However, there's content under the file views.py(OTM2/opentreemap/registration_backend/) that has some text that needs translating. I already tried to create a locale in the OTM2/opentreemap/ (this is the django project root, right?) but no success. Any suggestions?

P.S.: I'm new to django, so if you think i'm messing something up, please point me some link.

Thank you!

Robert Cheetham

unread,
Mar 20, 2015, 2:45:07 PM3/20/15
to opentree...@googlegroups.com
Filipe,

I will leave it to one of the developers to respond on the specifics.

However, I think it's really awesome that you are looking into translating OpenTreeMap for Portuguese.  Translation and internationalization is something around which we designed and planned in OpenTreeMap, but for which we don't yet have translation files for non-English languages.  This could be a huge contribution and I hope you'll consider submitting a pull request once you have developed a working version.


Best,

Robert


------------------
Robert Cheetham

Azavea  |  340 N 12th St, Ste 402, Philadelphia, PA
chee...@azavea.com  | T 215.701.7713 
Web azavea.com  |  Blog azavea.com/blogs  |  Twitter @rcheetham  and @azavea

Azavea is a B Corporation - we apply geospatial technology for civic and social impact
while advancing the state-of-the-art through research. Join us.


--
You received this message because you are subscribed to the Google Groups "opentreemap-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Filipe Marques

unread,
Mar 20, 2015, 3:34:56 PM3/20/15
to opentree...@googlegroups.com
Robert,

I'll try my best to make this available. The project is in great shape, almost everything is already tagged with the translation options provided by the python language. Just one more thing: i'm using the otm2-vagrant repo.

Best,

Filipe

Michael Maurizi

unread,
Mar 23, 2015, 10:33:53 AM3/23/15
to opentree...@googlegroups.com
Felipe,

Thanks so much for working on this!  I look forward to your contributions.

In general when translating Django apps, you should follow the guidelines in the Django Docs (https://docs.djangoproject.com/en/1.6/topics/i18n/translation/).

We're storing our locale files on an app by app basis.  You can see the locale files for English for the 'treemap' app stored here: https://github.com/OpenTreeMap/OTM2/tree/master/opentreemap/treemap/locale/en/LC_MESSAGES

We've scripted the creation of these files in our Fabric file here (https://github.com/OpenTreeMap/OTM2/blob/master/fabfile.py#L263-L295).

You'll need to install fabric on your host machine using 'sudo pip install fabric' to use this, but you can just as easily run the commands manually from inside your Vagrant VM..

If you're using fabric, you should be able to generate new messages file for Portuguese by running 'fab vagrant:.. make_messages:pt_PT' from the OTM2 directory on your host machine.
To get this to pick up the 'registration_backend' app, you'll have to add it to the list of Django Apps to translate here: https://github.com/OpenTreeMap/OTM2/blob/master/fabfile.py#L267.

You can do this from inside the VM without Fabric too.  If you SSH into the VM and source the Python Virtualenv using 'source /usr/local/otm/env/bin/activate', you should be able to generate locale files for a specific Django app by running 'django-admin.py makemessages --locale pt_PT' from the app directory.


Good Luck!
- Michael Maurizi
--
Michael V. Maurizi Jr
Software Developer
Azavea |  340 N 12th St, Suite 402, Philadelphia, PA
mmau...@azavea.com  | T 215.558.6190
Web azavea.com  |  Blog azavea.com/blogs  | Twitter @azavea

Filipe Marques

unread,
Mar 23, 2015, 3:17:50 PM3/23/15
to opentree...@googlegroups.com
Michael,

First of all, thank you for making things clear. I took a look at the fabfile.py and I guess all it does is generate the files for translation and compiles them(using makemessage and compilemessage). And the apps are 'treemap' and  'ecobenefits', but isn't ecobenefits a Go app? So I generate the files for the treemap and registration_backend files. However I couldn't get it to generate the translation files for treemap's js files. I changed USE_JS_I18N to true.

So just to make it clear, what do I do with the ecobenefits app and am I missing something with the js files?

P.S.: I'm running everything from the VM using the virtualenv provided by the otm2-vagrant repo.

Thank you for any input,

Filipe

Michael Maurizi

unread,
Mar 23, 2015, 3:53:25 PM3/23/15
to opentree...@googlegroups.com
Felipe,

Sorry for the confusion
We used to have a Django ecobenefits app.  We moved it over to a Go app for performance, and I guess we never changed that line in the fabfile.
You shouldn't have to do anything with the Go-based ecobenefits app.

As far as your issues with JS translation, I think you can safely ignore that at the moment, as we haven't been using the Django JS translation library, so it wouldn't pick up any strings to translate.

Thanks,
Michael Maurizi

Filipe Marques

unread,
Mar 23, 2015, 4:21:25 PM3/23/15
to opentree...@googlegroups.com
Michael,

Thank you for all the info, I'll see what's the best way to make the translation available since I'm not the project owner. Hopefully I'll be able to translate the Android/iOS app as well.

Thanks again!

Filipe Marques

unread,
Mar 26, 2015, 3:33:26 PM3/26/15
to opentree...@googlegroups.com
Hi,

I'm running in a bit of trouble. Under the url http://127.0.0.1:7070/sampa/features/1/ the page presents a tree detail view with its informations and there's two sections that i can't get to translate, they are "tree stewardship" and "planting site stewardship". Also, under the "last update" box on the left there's a bullet point "add a photo" I though it was the one in the map_feature_detail.html(line 24), however the translation doesn't occur. I guess that's all, i appreciate any input.

Thanks!

Filipe Marques

unread,
Mar 26, 2015, 4:44:14 PM3/26/15
to opentree...@googlegroups.com
Hi again,

Under the otm_comments app there's two files that contain text flagging.html and flagging.js. i'm adding them to the project anyways, but i'm afraid my project is already a mess and I won't be able to commit these changes to the official repo. Maybe I can help later with my findings in a way to decouple UI text from code.

Justin Walgran

unread,
Mar 27, 2015, 11:01:12 AM3/27/15
to opentree...@googlegroups.com
Stewardship is a unique feature and the fields are handled though a different code path we can did in and find where there may be missing translation directives.

Are the other bullet points (e.g. "Add the species") responding to translation?

Filipe Marques

unread,
Mar 27, 2015, 12:52:47 PM3/27/15
to opentree...@googlegroups.com
Just found the file that contains "add the species" and "add a photo" is the map_feature. I missed it, the thing is: using trans() won't work it needs to be _() or some other directives that the gettext lib will use.(i can't find the stackoverflow link right now). But the "stewardship" header is in the "collectionudf.html" line 9. My Django skills are too limited to understand a good way to translate this header, i'm sorry. Again, i appreciate any help.

Thanks, Justin!

Justin Walgran

unread,
Mar 30, 2015, 1:42:04 PM3/30/15
to opentree...@googlegroups.com
The development team decided to use trans rather than _ as our alias for ugettext, by convention. It is my understanding that it does not matter what alias name is used for the ugettext function. Our import:

from django.utils.translation import ugettext as trans

and the conventioanl Django import

from django.utils.translation import ugettext as _

should be functionally equivalent. The Django docs talk about how they differ from the Python standard library on treating "_" as a special case. If you have a specific example, or a link to a reference explaining a situation where "_" is required, it would help me understand the problem a bit more.



On the topic of translating the stewardship field header in collectionudf.html, I assume you are running into trouble on this line

<h4>{{ udf.model_type|display_name }} {{ udf.name }}</h4>

The names of "collection user-defined fields," like all user-defined, custom field, are actually stored in the database. We cannot translate these field names because they could be changed at any time, unlike the static text embedded in the application source code.

Filipe Marques

unread,
Mar 30, 2015, 2:54:22 PM3/30/15
to opentree...@googlegroups.com
Okay, I don't know how valid is the info, but as soon as I changed the alias from 'trans' to '_' in the python files the makemessages command was able to generate files. I found the link, here it is: http://stackoverflow.com/a/16510454.
As for the stewardship field header, you're correct. So if I need to change the database names in order to get a full translation of the app, right? I know I'm making a lot of changes and they're not what the opentreemap project expect/needs. So I'll try later on my free time to get it translated to portuguese in way that it works well for you guys :)

Thanks!

Justin Walgran

unread,
Mar 30, 2015, 4:01:09 PM3/30/15
to opentree...@googlegroups.com
Thanks for replying with that link, Filipe. We chose to use "trans" as our alias because it matched the "trans" template tag. It looks like we may have to change this across the application. Sorry that this hidden problem has gotten in the way of your translation. I have opened an issue for the team to work on resolving this and have added your excellent research to the issue notes.

Yes, translating the title for the stewardship user-defined field would need to be done in the database.


Nico Aliotta

unread,
Apr 1, 2016, 12:14:34 PM4/1/16
to opentreemap-user
This post is very old so let me know if something has been changed.

I want to translate OTM in italian and i found that i've this file:
C:\cygwin64\home\Nico\otm-vagrant\otm-core\opentreemap\locale\en\LC_MESSAGES

can i add Italian Folder:
C:\cygwin64\home\Nico\otm-vagrant\otm-core\opentreemap\locale\IT\LC_MESSAGES

and choice if i want to use italian or english language?

Is the right way to translate OTM?

Justin Walgran

unread,
Apr 1, 2016, 5:33:37 PM4/1/16
to opentree...@googlegroups.com
Nico,

We do not have any translations in production yet, so this is a new process for everyone. I tested the following workflow in my development environment and I was able to see translated strings appear in the application.

1) Install the translation tools

$ sudo apt-get install gettext

2) Generate .po files

$ cd {{ path to otm-core }}/opentreemap && ./manage.py makemessages --locale it
$ cd {{ path to otm-core }}/opentreemap/treemap && ../manage.py makemessages --locale it

3) Translate the .po files. 

Fill in msgstr values in {{ path to otm-core }}/opentreemap/locale/it/LC_MESSAGES/django.po
Fill in msgstr values in {{ path to otm-core }}/opentreemap/treemap/locale/it/LC_MESSAGES/django.po

You can use a plain text editor, or use one of several graphical tools to edit these files. I do not have experience with any of the graphical tools, so I cannot speak to their quality, but both of these offer Windows versions


4) Compile the .po files into .mo files

$ cd {{ path to otm-core }}/opentreemap && ./manage.py compilemessages
$ cd {{ path to otm-core }}/opentreemap/treemap && ../manage.py compilemessages

5) Set the default language and disable automatic language detection

Edit {{ path to otm-core }}/opentreemap/opentreemap/settings/default_settings.py and make the following changes

5.1) Set the language code to Italian

LANGUAGE_CODE = ‘it-IT'

5.2) Disable language detection by commenting out LocaleMiddleware within the MIDDLEWARE_CLASSES tuple.

MIDDLEWARE_CLASSES = (
    ...
    # 'django.middleware.locale.LocaleMiddleware',
    ...
)

6) Restart gunicorn so the settings file is reloaded.



Nico Aliotta

unread,
Apr 3, 2016, 11:30:58 AM4/3/16
to opentreemap-user
Thanks
i've a problem generating .po files

Nicow8@Nico-dev ~/otm-vagrant/otm-core
$ cd opentreemap && ./manage.py makemassages --locale it
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management


Michael Maurizi

unread,
Apr 4, 2016, 11:19:59 AM4/4/16
to opentreemap-user
Nico,

You need to run all 'manage.py ...' commands from inside the VM.

Mike

--
You received this message because you are subscribed to the Google Groups "opentreemap-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Michael Maurizi, Software Developer
Azavea |  340 N 12th St, Ste 402, Philadelphia, PA
mmau...@azavea.com | Web azavea.com  |  @azavea

-----
We'll be moving on March 1, 2016. Please update your records with our new address:
990 Spring Garden Street, 5th Floor
Philadelphia, PA 19123
----

Nico Aliotta

unread,
Apr 5, 2016, 12:54:01 PM4/5/16
to opentreemap-user

On point 4 i've:

vagrant@vagrant-ubuntu-trusty-64:/usr/local/otm/app/opentreemap$ ./manage.py compilemessages
/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py:159: RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class ContentType(models.Model):

/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Site(models.Model):

/usr/local/lib/python2.7/dist-packages/django_comments/models.py:51: RemovedInDjango19Warning: Model class django_comments.models.Comment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Comment(BaseCommentAbstractModel):

/usr/local/lib/python2.7/dist-packages/django_comments/models.py:176: RemovedInDjango19Warning: Model class django_comments.models.CommentFlag doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class CommentFlag(models.Model):

/usr/local/lib/python2.7/dist-packages/threadedcomments/models.py:10: RemovedInDjango19Warning: Model class threadedcomments.models.ThreadedComment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class ThreadedComment(Comment):

/usr/local/otm/app/opentreemap/otm_comments/models.py:14: RemovedInDjango19Warning: Model class otm_comments.models.EnhancedThreadedComment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class EnhancedThreadedComment(ThreadedComment):

/usr/local/otm/app/opentreemap/otm_comments/models.py:56: RemovedInDjango19Warning: Model class otm_comments.models.EnhancedThreadedCommentFlag doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class EnhancedThreadedCommentFlag(models.Model, Auditable):

processing file django.po in /usr/local/otm/app/opentreemap/locale/en/LC_MESSAGES
processing file django.po in /usr/local/otm/app/opentreemap/locale/it/LC_MESSAGES

i can see the files compiled but seems that nothing is changed on the browser page also after a refresh.

I also closed and reopened the VM with vagrant up and rsync. But nothing changed.


Justin Walgran

unread,
Apr 6, 2016, 5:02:13 PM4/6/16
to opentree...@googlegroups.com
You also need to compile messages for the treemap application

$ cd {{ path to otm-core }}/opentreemap/treemap && ../manage.py compilemessages

Did you do that?

Message has been deleted

Nico Aliotta

unread,
Apr 7, 2016, 9:43:25 AM4/7/16
to opentreemap-user
Yes i did it:

If you want i can post here my django.po with translations so you can test and if someone in the future want to use it in italian is available.

vagrant@vagrant-ubuntu-trusty-64:/usr/local/otm/app/opentreemap/treemap$ ../manage.py compilemessages

/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py:159: RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class ContentType(models.Model):

/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Site(models.Model):

/usr/local/lib/python2.7/dist-packages/django_comments/models.py:51: RemovedInDjango19Warning: Model class django_comments.models.Comment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Comment(BaseCommentAbstractModel):

/usr/local/lib/python2.7/dist-packages/django_comments/models.py:176: RemovedInDjango19Warning: Model class django_comments.models.CommentFlag doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class CommentFlag(models.Model):

/usr/local/lib/python2.7/dist-packages/threadedcomments/models.py:10: RemovedInDjango19Warning: Model class threadedcomments.models.ThreadedComment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class ThreadedComment(Comment):

/usr/local/otm/app/opentreemap/otm_comments/models.py:14: RemovedInDjango19Warning: Model class otm_comments.models.EnhancedThreadedComment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class EnhancedThreadedComment(ThreadedComment):

/usr/local/otm/app/opentreemap/otm_comments/models.py:56: RemovedInDjango19Warning: Model class otm_comments.models.EnhancedThreadedCommentFlag doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class EnhancedThreadedCommentFlag(models.Model, Auditable):

processing file django.po in /usr/local/otm/app/opentreemap/treemap/locale/en/LC_MESSAGES
processing file django.po in /usr/local/otm/app/opentreemap/treemap/locale/it/LC_MESSAGES

Nico Aliotta

unread,
Apr 7, 2016, 2:03:12 PM4/7/16
to opentreemap-user
After 2 vagrant rsync i can see the italian Version :)

I don't know why at first rsync nothing happened!

Thanks for the help.

Next step for me is to set up the android app. Stay tuned i'll bore you (as always) with the app now :)

Is there any news about the upgrade of the otm installation tutorial?

Justin Walgran

unread,
May 2, 2016, 11:38:41 AM5/2/16
to opentreemap-user
All,

I misunderstood the way the translation tooling works and have been advising people to generate and translate .po files for both the root opentreemap application and the nested opentreemap/treemap application. This is not necessary. All of the msgids in the opentreemap/treemap file already exist in the top-level opentreemap file. Sorry for any confusion.

-Justin
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-user+unsubscribe@googlegroups.com.

Ricard Roca Munárriz

unread,
May 10, 2016, 11:07:59 AM5/10/16
to opentreemap-user
Hello,

I translated both .po files and compile them, but unfortunately I only see some of the texts tranlates. The ones not translated are the ones in the html files using trans directive.
Is there any way to fix this or any temporary workaround?

Thanks

El dilluns, 2 maig de 2016 17:38:41 UTC+2, Justin Walgran va escriure:
All,

To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-us...@googlegroups.com.

Ricard Roca Munárriz

unread,
May 12, 2016, 1:15:44 PM5/12/16
to opentreemap-user
Well I found the solution in stackoverflow. I added this line to LOCALE_PATHS = ('../locale','../treemap/locale') to local_settings.py and everything works.

Hope it helps


El dimarts, 10 maig de 2016 17:07:59 UTC+2, Ricard Roca Munárriz va escriure:

Nico Aliotta

unread,
May 28, 2016, 2:05:48 PM5/28/16
to opentreemap-user
I cannot see the string translated in italian on my server. In vagrant all was fine with instructions of Rick.

Do you confirm that we need only django.po in folder /usr/local/otm/app/opentreemap/locale/it/LC_MESSAGES ?

seems that /usr/local/otm/app/opentreemap/treemap/locale/it/LC_MESSAGES/django.po  is bigger than the other one.

What i did:

1) I copyed and pasted the django.po file that i generated on vagrant in the server in this folder:
/usr/local/otm/app/opentreemap/locale/it/LC_MESSAGES

2) cd  /usr/local/otm/app/opentreemap && ./manage.py compilemessages

3) Edited  /usr/local/otm/app/opentreemap/opentreemap/settings/default_settings.py in this way

LANGUAGE_CODE = 'it-IT'
and commented the LocaleMiddleware within the MIDDLEWARE_CLASSES tuple.

MIDDLEWARE_CLASSES = (
    ...
    # 'django.middleware.locale.LocaleMiddleware',
    ...
)
4) restarted gunicorn and all other services

5) i also added  LOCALE_PATHS = ('../locale','../treemap/locale') in local_settings.py as suggested by Ricard Roca
but i see all text in english
Reply all
Reply to author
Forward
0 new messages