Quantcast

I18n and 'Accept-Language' header?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

I18n and 'Accept-Language' header?

Tony Graham
http://exist-db.org/exist/apps/demo/examples/special/i18n-docs.html#usage 
states:

----
The language to use for internationalization can be chosen in various ways

  - via http parameter 'lang', e.q http://exist/index.html?lang=de
  - as xquery parameter $selectedLang if the i18n module is called
    directly
  - xml:lang attribute on the root node of the markup to process
----

Why doesn't the i18n module also have a fourth (or possibly
two-and-a-halfth) alternative of finding the language from the HTTP
'Accept-Language' header, e.g.:

----
Accept-Language: ja,en;q=0.7,en-GB;q=0.3
----

?

I could, of course, modify my app to start passing around a 'lang'
parameter, but I'm wondering why I should have to instead of having the
option of defaulting to using the browser's opinion of the language to use.

Regards,


Tony Graham.
--
Senior Architect
XML Division
Antenna House, Inc.
----
Skerries, Ireland
[hidden email]

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: I18n and 'Accept-Language' header?

Wolfgang Meier-2
> Why doesn't the i18n module also have a fourth (or possibly
> two-and-a-halfth) alternative of finding the language from the HTTP
> 'Accept-Language' header, e.g.:

There’s a slightly extended version of the i18n module below, which checks the Accept-Language header:

http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/lib/i18n.xql

I planned to either move this back to demo-apps or - preferably - we should extract everything into a separate i18 package to be used by all apps.

Wolfgang
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: I18n and 'Accept-Language' header?

Tony Graham
On 19/05/2017 16:52, Wolfgang Meier wrote:
>> Why doesn't the i18n module also have a fourth (or possibly
>> two-and-a-halfth) alternative of finding the language from the HTTP
>> 'Accept-Language' header, e.g.:
>
> There’s a slightly extended version of the i18n module below, which
> checks the Accept-Language header:
>
> http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/lib/i18n.xql

Thanks.  However, that could now do with the typo fixes from
https://github.com/eXist-db/demo-apps/pull/22

I appreciate that this version can return arbitrary nodes rather than
just one text node, since I have some text to translate that currently
has a <br/> in the middle of it.

Can you explain basing the language selection on @xml:lang?  I can't
work out when that would be useful.

If the preferred method of setting the language is a 'lang' HTTP
parameter, how do you set the parameter in @href in template pages such
as
https://github.com/wolfgangmm/eXide/blob/develop/templates/existdb/templates/page.html?

> I planned to either move this back to demo-apps or - preferably - we
> should extract everything into a separate i18 package to be used by
> all apps.

A separate package would suit me better, I think.

Regards,


Tony Graham.
--
Senior Architect
XML Division
Antenna House, Inc.
----
Skerries, Ireland
[hidden email]

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...