Can website visitors update my languages files?

53 views
Skip to first unread message

mwolfe02

unread,
Jan 14, 2016, 2:41:04 PM1/14/16
to web2py-users
I've got a live web2py application under Mercurial version control.  When I did my latest commit, I noticed there were several changes to the following two files (the Polish and Russian translation files):

/languages/pl.py
/languages/ru-ru.py

I did not make these changes.  The changes look like they could be legitimate and perhaps automated.  For example, here are the first few lines of the ru-ru.py diff (I removed some characters and replaced them with {...} to limit the amount of noise:


@@ -1,87 +1,91 @@
-# coding: utf8
+# -*- coding: utf-8 -*-
 {
-'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"\xd0\x98\xd0{...}\xd1\x8c.',
+'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"Изм{...}ть.',
+'%s rows deleted': '%s строк удалено',
+'%s rows updated': '%s строк изменено',
 '%Y-%m-%d': '%Y-%m-%d',
 '%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',


So what could have caused these changes?  Does web2py itself do something that would cause this?  Google Translate?  Website visitors?  Apache?

Are there security considerations I should be aware of?

As far as I know, I have not done anything to modify the default Translation behavior of my app.

Thanks in advance to anyone who can enlighten me,
Mike Wolfe

Anthony

unread,
Jan 14, 2016, 3:32:53 PM1/14/16
to web2py-users
The first time a visitor requesting a particular language hits the app, any T() items not yet in the associated translation file will be added automatically for later translation.

Anthony

Michael Wolfe

unread,
Jan 14, 2016, 3:40:47 PM1/14/16
to web...@googlegroups.com
That makes sense.  I guess my question is where do the translations themselves come from?  For example, the following two lines were *added* to the Russian translation file:


'%s rows deleted': '%s строк удалено',
'%s rows updated': '%s строк изменено',

I certainly did not add in the Cyrillic characters in the above lines.  So where did they come from?

There are some lines that were just changed from their hex code to the Unicode characters (e.g., "\xd0\x98\xd0\xb7\xd0\xbc" to "Изм").  That I can understand.  It's the brand new translations that I was surprised by.  Could they be coming from the languages files in the example app?

Thanks,
Mike

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/46XERxrdvts/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Jan 14, 2016, 5:34:10 PM1/14/16
to web2py-users
web2py comes with many phrases already translated (e.g., those used in admin and appadmin):

https://github.com/web2py/web2py/blob/master/applications/welcome/languages/ru.py#L13

Anthony
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Michael Wolfe

unread,
Jan 14, 2016, 6:32:43 PM1/14/16
to web...@googlegroups.com

OK. So the framework is updating the languages files in my app based on translations in other apps (e.g., admin and appadmin)?

But only if a website visitor requests a page in that language, correct?

So I'm imagining the following algorithm:

- website visitor with a 'pl' language preference visits my site
- goes to a page with T("Hello")
- web2py looks for /myapp/languages/pl.py
- web2py looks for "Hello" in that file
- can't find it, so it checks /appadmin/languages/pl.py
- finds a translation in that file
- updates /myapp/languages/pl.py with this translation
- shows visitor the translated text

Is that about right?

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/46XERxrdvts/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Anthony

unread,
Jan 14, 2016, 7:30:17 PM1/14/16
to web2py-users
On Thursday, January 14, 2016 at 6:32:43 PM UTC-5, mwolfe02 wrote:

OK. So the framework is updating the languages files in my app based on translations in other apps (e.g., admin and appadmin)?


No, I shouldn't have mentioned admin. But appadmin is part of your app, so yes, strings in appadmin do contribute to the language files in your app. Translations in one app, however, do not affect those in others.

Anyway, my point was that the specific translations to which you were referring are provided with the web2py distribution (the link I included shows where those translations are in the .ru file of the welcome app) -- they are not generated dynamically. Those particular phrases are likely from appadmin, which is why they are included in the default translation files.

Anthony
Reply all
Reply to author
Forward
0 new messages