Add Accept-Language header to request
-
Hi,
there are servers out there, which return events different depending on the locale of the client (ownClouds contact birthdays for example)
This might not be the best choice for the server, but there is simple solution to get the events in the locale of the device:In HttpClient add:
@RequiredArgsConstructor static class LanguageInterceptor implements Interceptor { final String language; @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request().newBuilder() .header("Accept-Language", language + ",*;q=0.5") .build(); return chain.proceed(request); } }
and then add to the constructor:
// add Accept-Language to every request networkInterceptors().add(new LanguageInterceptor(context.getResources().getConfiguration().locale.toString()));
There may even be the possibility to configure a different locale for each account, but that is probably overkill…
Jochen
-
Hello,
Interesting idea. Does ownCloud generate such event summaries per language? Is it only for birthdays?
-
@rfc2822 said:
Hello,
Interesting idea. Does ownCloud generate such event summaries per language?
I do not know for sure…
I think owncloud persists soe meta data for the birthday event. But the VEVENT is generated for every request.
This way the calendar entries in the web are always shown in the locale of the page (browser locale)Is it only for birthdays?
As far as I can tell: Yes
But owncloud is an open framework and even ‘contacts’ is an app now.
So there may well be other apps around, that do similar thingsYes, but why install another app on my mobile device when I can have the same result by just ticking a checkbox in DAVdroid
An then it is also always consistent with the web view.