Closed wasade closed 10 years ago
This seems like an overall good strategy. I am sure you guys revised this but I am curious about it, why can we not use any of the available packages to do localization?
Any specific suggestions? We looked briefly at the locale package in python, and although it could help with some things (such as which punctuation mark to use to denote deimals versus thousands separators), I think this is the more "complete" solution; I have never used any of those packages though, so it's very possible I am underestimating their utility.
On Wed, Sep 24, 2014 at 6:54 PM, Yoshiki Vázquez Baeza < notifications@github.com> wrote:
This seems like an overall good strategy. I am sure you guys revised this but I am curious about it, why can we not use any of the available packages to do localization?
— Reply to this email directly or view it on GitHub https://github.com/biocore/american-gut-web/issues/58#issuecomment-56760594 .
Just as a heads up: adding {% autoescape None %}
to the top of a template means that none of the variables will be autoescaped, so raw is not needed.
uh, guys.... http://www.tornadoweb.org/en/branch2.2/locale.html
@squirrelo, have you ever read an automatic translation that you liked?
@squirrelo, are you sure that it is safe to have all variables treated as raw? This way we can at least be specific and it is like 3 extra characters to type per variable
Fair on the raw bit, but the translations actually come from a CSV file you create. Take a look at http://www.tornadoweb.org/en/branch2.2/locale.html#tornado.locale.load_translations
We still need to do the breakout of text, but in a completely different way in that case.
I don't think we want to write out all conjugated forms of all the verbs used in the AG site. My read on that method is that it is for translating, not for replacing already translated strings
On Thu, Sep 25, 2014 at 4:45 PM, Joshua Shorenstein < notifications@github.com> wrote:
Fair on the raw bit, but the translations actually come from a CSV file you create. Take a look at http://www.tornadoweb.org/en/branch2.2/locale.html#tornado.locale.load_translations
We still need to do the breakout of text, but in a completely different way in that case.
— Reply to this email directly or view it on GitHub https://github.com/biocore/american-gut-web/issues/58#issuecomment-56895169 .
btw, I'm moving on sitebase.html but probably won't finish it tonight
It's for both. And we don't have to worry about the translation of verbs, as "For strings with no verbs that would change on translation, simply use “unknown” or the empty string (or don’t include the column at all)." Since we are just doing direct translation it should be a straight replace operation in tornado. I'll play with it tomorrow morning and see if this will make life easier.
Awesome, sounds goos On Sep 26, 2014 12:05 AM, "Joshua Shorenstein" notifications@github.com wrote:
It's for both. And we don't have to worry about the translation of verbs, as "For strings with no verbs that would change on translation, simply use “unknown” or the empty string (or don’t include the column at all)." Since we are just doing direct translation it should be a straight replace operation in tornado. I'll play with it tomorrow morning and see if this will make life easier.
— Reply to this email directly or view it on GitHub https://github.com/biocore/american-gut-web/issues/58#issuecomment-56922979 .
Playing with a toy example, and tornado.locale seems to do everything we want and more. We can even set it up with variables inside the translation strings so we can insert the project name programmatically instead of directly within the translation strings.
That is awesome, we can give it a go at the full website, worst case scenario we go back to the previous plan, best case scenario we "only" need to translate strings.
On (Sep-26-14|10:02), Joshua Shorenstein wrote:
Playing with a toy example, and tornado.locale seems to do everything we want and more. We can even set it up with variables inside the translation strings so we can insert the project name programmatically instead of directly within the translation strings.
Reply to this email directly or view it on GitHub: https://github.com/biocore/american-gut-web/issues/58#issuecomment-56989663
Yup yup. I can demo the toy example after lunch, when I get back to the building.
Do you have an example? Should we stop the current efforts right now or is that effort still necessary?
What time? I need to leave by about 12:20 for the rest of the day btw...
I have an example. Unzip this and then run "python tornadolocale.py" to play with the toy. the index should stay at whatever language you were at last, while the /en/
and /de/
pages should be english and german, respectively.
https://dl.dropboxusercontent.com/u/39899821/localetest.zip
@wasade I'd say pause current development for now and see if that toy example will work for what we need to do.
The tornado examples all are oriented around phrases, not paragraphs. From looking at the source, it looks like the translation will just be a look up of the full string (e.g., a paragraph) in to a dict
to get a translated version. That seems fine, but I'm very nervous about maintenance as, moving forward, we'd need to modify the presented string (such as those currently in the templates) as well as each locale dict as it is the presented string that is the key
What about: "present text": "texto actual" "present text": "future text" ?
Yes, that is what tornado is doing, which means that if you have N supported languages, anytime you update english text (like changing "Add Human Source" to "Add human source"), you need to make that change in N+1 locations. This will be a nightmare for long paragraphs when doing small grammatical changes
I see, luckily we will only support N < 5, right? :)
For N=2 this is a nightmare.
What are the benefits to using tornado's locale?
@teravest just pointed out that we could have a en_USv1 look up, which lets use preserve all the current strings and essentially requires that all strings are translated. This greatly simplifies everything as the templates then can be filled with a key such as "SITEBASE_NAV_ADD_HUMAN", which is a key in the translation files. That works, but we still need to separately address branding
That sounds like a good idea. As for branding, I would be surprised if tornado didn't provide something like that already as it is a very standard problem.
On (Sep-26-14|11:02), Daniel McDonald wrote:
@teravest just pointed out that we could have a en_USv1 look up, which lets use preserve all the current strings and essentially requires that all strings are translated. This greatly simplifies everything as the templates then can be filled with a key such as "SITEBASE_NAV_ADD_HUMAN", which is a key in the translation files. That works, but we still need to separately address branding
Reply to this email directly or view it on GitHub: https://github.com/biocore/american-gut-web/issues/58#issuecomment-56997897
Agree, though we can always fall back on the replacements anyway. Hows this sound then for the translations:
{% raw _('SOME_VARIABLE') %}
SITEBASE_NAV_ADD_HUMAN_SOURCE
Sound good? We also of course need to get the translation support hooked up in webserver.py
This sounds like a good course of action. :+1:
On (Sep-26-14|11:20), Daniel McDonald wrote:
Agree, though we can always fall back on the replacements anyway. Hows this sound then for the translations:
- all text needs to be pulled out and replaced with `{% raw _('SOME_VARIABLE') %}
- variable names used in templates must be unique and make sense (e.g.,
SITEBASE_NAV_ADD_HUMAN_SOURCE
- en_USv1 is created keyed by the variables, valued by the present text on the website
- google spreadsheet is updated as we planned except using the more explicit variable names
Sound good? We also of course need to get the translation support hooked up in webserver.py
Reply to this email directly or view it on GitHub: https://github.com/biocore/american-gut-web/issues/58#issuecomment-57000720
Sounds good to me. And actually the %(blah) style of variables in the example works regardless of how we do the translations, so we can do single translations for multiple projects and just sub in the project name programatically.
@squirrelo would you mind opening a pull request with this setup or if you need help we can work on it on monday.
I'm @ A222 if you would like to work today.
I'm working on the FAQ page right now so I can open a pull request on the unfinished version I have just for an example.
That would be awesome, thanks!
On (Sep-26-14|15:37), Joshua Shorenstein wrote:
I'm working on the FAQ page right now so I can open a pull request on the unfinished version I have just for an example.
Reply to this email directly or view it on GitHub: https://github.com/biocore/american-gut-web/issues/58#issuecomment-57029460
BTW in doing this I found that since we are mimicking the tornado.locale thing with our own dicts, we really don't need it. It was a good idea, but we are too text-heavy and text-changey to have it work properly.
Just realized following the work on #69 that we can just include text_locale
in the templates which mean that we do not need to update the handlers. Will have an example up in a second
See #70, this approach lets us not even have to modify the handlers and all the work can be done in the template. Basically, you just add:
{% from amgut import text_locale %}
{% set tl = text_locale['forgot_password.html'] %}
Into {% block content %}
. It is sensitive to where these lines are placed, and the best place seemed like block content
. I tried putting into block content
in no_auth_sitebase.html
and it wouldn't work, and placing at the top of the file (prior to block head
) didn't work either for some reason. WIll update the sitebase PR since that was encompasing...
nm, not appropriate for the sitebase PR. Will issue a subsequent PR to get help_request fixed and will address the other PRs in the process. @squirrelo, just a heads up since I know you're working on FAQ
Thanks, added into the FAQ page.
@ElDeveloper and @squirrelo, either of you working on addendum.html
right now? If not, I'm on it
...rather, I am working on it now, just fyi
Sounds good.
Yoshiki Vázquez-Baeza
On Sep 29, 2014, at 7:33 PM, Daniel McDonald notifications@github.com wrote:
...rather, I am working on it now, just fyi
— Reply to this email directly or view it on GitHub.
Was just about to, but not now!
Is anyone working on animal_survey right now?
The surveys have some oddities as I understand, @adamrp, can you comment please?
On Mon, Sep 29, 2014 at 7:38 PM, Joshua Shorenstein < notifications@github.com> wrote:
Is anyone working on animal_survey right now?
— Reply to this email directly or view it on GitHub https://github.com/biocore/american-gut-web/issues/58#issuecomment-57256048 .
righto, I'll work on change_pass_verify and participant_overview then.
Also, the international page is going to be interesting to do as it already has built in translations. Anyone want to take a crack at it or do we need to discuss what to do with that page?
we should discuss at AG tomorrow about the international page
I just started working with the animal_survey.html and found that the options of the animal type are coded in english. Basically that the option Dog has a value of Dog vs. option Dog - value 1. I can leave it like this or change it but not sure about the consequences of either option. What do you think will be the best?
@adamrp has the most up to date knowledge of the surveys On Sep 30, 2014 8:29 AM, "Antonio Gonzalez" notifications@github.com wrote:
I just started working with the animal_survey.html and found that the options of the animal type are coded in english. Basically that the option Dog has a value of Dog vs. option Dog - value 1. I can leave it like this or change it but not sure about the consequences of either option. What do you think will be the best?
— Reply to this email directly or view it on GitHub https://github.com/biocore/american-gut-web/issues/58#issuecomment-57322296 .
Okay, looks like just international.html
and the surveys. Lets discuss these at the AG meeting. I'm starting on #89, which I think is the last blocker for sending content to the British Gut
I believe only animal_survey
is left to do, pending doing this in non-English English first
animal_survey
questions and responses are in #141. These are not going into BG locale dict as they will be sourced from the db
Any text that is displayed to the user will need to be pulled out into project/locale specific dicts. These dicts will be located under
amgut.lib.locale_data
, and each portal will have its own. For instance, the American Gut portal text and media will fall underamgut.lib.locale_data.american_gut
. The motivation for portal specific, instead of language specific localization is that many countries rely on en_UK, but we need to play for having different branding (e.g., Australian Gut) moving forward.Each
locale_data
module needs to provide two dicts,text_locale
andmedia_locale
. The structure oftext_locale
is as follows:text_locale
is per-template which minimizes what needs to be passed intorender
from the handlers.media_locale
is not per-template as much of the media is common across templates, such as the logo.In the
__init__
foramgut.lib.locale_data
, there is amedia_locale
that represents anything common regardless of portal. Thisdict
is updated by the project specificmedia_locale
.For localization data, all handlers will need to add:
The package-level
__init__
will resolve the appropriate locale data. All handlers wishing to use the locale data will need to specify the locale over render. For instance:Within the templates, all user visible text will need to be replaced with:
All variables should be expressed with
raw
, which will let us preserve html formatting and tags within the locale dicts.And finally, the list of templates to knock off. A template is considered completed once the text has been pulled out and replaced with locale lookups, the relevant locale entries updated, and the handler has been updated.