Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 21 19:12
    KoalaGeo edited #820
  • Jan 20 15:09
    KoalaGeo commented #835
  • Jan 20 15:09
    KoalaGeo commented #835
  • Jan 20 07:22
    dthib commented #835
  • Jan 20 01:42
    KoalaGeo commented #835
  • Jan 19 22:01
    dthib edited #842
  • Jan 19 22:01
    dthib labeled #842
  • Jan 19 22:01
    dthib opened #842
  • Jan 19 20:55
    dthib commented #835
  • Jan 19 16:38
    KoalaGeo commented #821
  • Jan 15 22:16
    tomkralidis commented #791
  • Jan 15 12:30

    tomkralidis on master

    allow providers to specify cust… (compare)

  • Jan 13 23:30
    tomkralidis milestoned #841
  • Jan 11 09:17
    francbartoli commented #801
  • Jan 11 09:08
    justb4 commented #801
  • Jan 10 20:11
    KoalaGeo commented #801
  • Jan 10 20:09
    KoalaGeo commented #835
  • Jan 10 19:11
    KoalaGeo commented #801
  • Jan 10 16:28
    tomkralidis commented #801
  • Jan 10 14:43
    justb4 commented #801
Sander Schaminee
@GeoSander
If it's omitted or None, the plugin will simply not have locale support but it won't break anything
Note that pygeoapi always has to pass the "raw" locale (as requested in the l query param or Accept-Language header) to the plugin, as the plugin might support other locale(s) than pygeoapi itself

@GeoSander can we go with lang= instead of l= ?

I prefer lang too actually, but went with what @pvgenuchten suggested ;)

Tom Kralidis
@tomkralidis
is the core driver of this PR multilingual for the UI or the pure JSON API?
Sander Schaminee
@GeoSander

maybe we can just take the second as the default? So the first one would become no longer valid?

I'd be happy to implement it like that (and keep the code a bit cleaner), but I thought it might be safer to have it support both for a while, as to not break any existing setups and not force people to use a multilingual configuration

is the core driver of this PR multilingual for the UI or the pure JSON API?

Both

But JSON responses returned by a provider for example get a Content-Language header that matches the provider locale, if available. If the provider does not support locales, no Content-Language header is set.
paul van genuchten
@pvgenuchten
but the pr focusses on the json part, the ui part will be in a next pr
Sander Schaminee
@GeoSander
Note that there's documentation for users, maintainers and plugins developers included in this PR
Tom Kralidis
@tomkralidis
you mean JSON responses returned by the server, not by the provider, no?
16 replies
I’ve added @kalxas @justb4 and @francbartoli to additionally review this PR
Sander Schaminee
@GeoSander

you mean JSON responses returned by the server, not by the provider, no?

Yes (but indirectly by the provider)

And thanks for taking the time to review and adding additional reviewers.
I'm open for any suggestions/improvements.
Need to go now, will check later for any messages
paul van genuchten
@pvgenuchten
I deployed the multilingual branch here
paul van genuchten
@pvgenuchten
A sparql backend would typically return localized responses, for the traditional data formats, the python provider code could manage about it
For elastic, I’m not sure what the current localization support is
paul van genuchten
@pvgenuchten
2 replies
paul van genuchten
@pvgenuchten
just created this issue geopython/pygeoapi#663, it gives potential approaches to add multilingual support to the csv provider
Tom Kralidis
@tomkralidis
can we keep the multilingual out of providers by default? For those who need multilingual, it can be added in the provider_def dict that gets passed (which is the provider block in config
Sander Schaminee
@GeoSander
Yes, I have been thinking of adding that to the passed-in definition, but I didn't like the idea of manipulating the definition (which should be static imho) with a dynamic parameter that could theoretically change for each request
Tom Kralidis
@tomkralidis
good point
Sander Schaminee
@GeoSander
Note that the provider_def has already has a languages section that states the supported languages. I could let the core find a best match for those languages and pass that along to the providers that need it. As @francbartoli already mentioned, I could introduce extra base classes that creators of multilingual providers can use. Then, the load_plugin function can pass that parameter if it sees that the provider implements that base class.
Tom Kralidis
@tomkralidis
What does MapServer do for language handling on data connections?
2 replies
as far as the backends, language would obviously be passed in the query functions. Why do we need it in the constructor?
Sander Schaminee
@GeoSander
That's an option too. However, get (for a single identifier) would also need it and possibly get_fields too
(I actually noticed that in some places, the fields property is used, which is set at provider class init, while at other places, the function is used)
Sander Schaminee
@GeoSander
Since the provider class is reloaded on each request, it's cleaner to set the language once, I think. I wish I could do the same to the API class, but then people could set other people's language :D
We'd be forced to start using sessions then...
Tom Kralidis
@tomkralidis

(I actually noticed that in some places, the fields property is used, which is set at provider class init, while at other places, the function is used)

We should be using just the .fields property from pygeoapi/api.py. There’s one of of get_fields() in pygeoapi/api.py that slipped in during the EDR API pull request. I can remove that once we have consensus on this PR

That's an option too. However, get (for a single identifier) would also need it and possibly get_fields too

If this removes the lang option from providers, I think it’s worth it, what do others think?

Sander Schaminee
@GeoSander
You mean the language parameter from the __init__ of the provider class?
Tom Kralidis
@tomkralidis
yes, only pass language to the query or get functions?
Sander Schaminee
@GeoSander
As yet another parameter... Well, I noticed you already started using **kwargs in the EDR provider, so we could throw anything at it, I guess :)
paul van genuchten
@pvgenuchten
no, i'm in favour to have language, like format and schema as explicit parameters
but we could add it only to the relevant methods and not to all
Sander Schaminee
@GeoSander
Me too. And having the base class deal with the logic to find the best matching look language is more elegant and easier to use for plugin developers
But I do like @francbartoli 's idea actually to make a language-aware base class that deals with this stuff that provider classes can implement. All current providers won't have to implement that so they stay the way they are now (no extra parameters).
paul van genuchten
@pvgenuchten
does it mean you pass in the (web)request object and the base class extracts the relevant language from it?
Sander Schaminee
@GeoSander
That could be an idea yes
paul van genuchten
@pvgenuchten
but what if pygeoapi is used outside a web-request scope
for example to render something in a desktop application
(not sure if that is possible)
the desktop app would need to mimic a web request to feed to the provider?
1 reply
Sander Schaminee
@GeoSander
Me neither :)
paul van genuchten
@pvgenuchten
to me parsing request parameters is something which should be managed in a generic module, not in a provider...
Sander Schaminee
@GeoSander
It is handled in the l10n module actually (using the get_plugin_locale function), but because the provider stores that locale property now, the provider calls that function