Translation problem with Google calendar

Plugin Author
room34

(@room34)

Unfortunately ICS Calendar can’t translate any of the text that is contained within the feed itself. However, you may be able to change the language Google is using when generating the feed:

https://support.google.com/calendar/answer/50640

The calendar is already in french. I was thinking of using something like that in ICS:

curl_setopt($ch, CURLOPT_HTTPHEADER, [‘Accept-Language: fr’]);

Plugin Author
room34

(@room34)

Ah… that’s an interesting idea. If you want to test it out, you could edit the class-r34ics.php file, inserting that line of code into the _url_get_contents() method around line 1926. Note that in this method, the connection variable is $conn not $ch so the code would look like this:

curl_setopt($conn, CURLOPT_HTTPHEADER, ['Accept-Language: fr']);

If that works, I can update the plugin to include that line, dynamically inserting the site’s configured language.

It works. Not sure if you should use the site language or the browser language however…

Plugin Author
room34

(@room34)

Thanks… you make a good point about the site language vs. the browser language, but everything else (i.e. month and day names) is getting translated on the server side based on the site language, so I think for consistency that’s probably the best approach. (Also I don’t think there’s a way in this particular context to know the browser language anyway.)

Maybe months and day names should be based on the browser language (that’s the way GC does it)… Plus an option to use the server language if one really don’t like it.

Plugin Author
room34

(@room34)

That’s not really a viable option. ICS Calendar is using built-in WordPress functions to handle all of those translations. It’s all (of functional necessity) server-side logic.

Plugin Author
room34

(@room34)

Upon a bit more investigation… it looks like it may be possible to code the plugin to use the browser’s language instead of the site’s configured language, by using the PHP $_SERVER['HTTP_ACCEPT_LANGUAGE'] variable. But it will be a more substantial undertaking than I can quickly roll out in a minor update (which is what I am planning to do with this code change we’ve been discussing so far).

(One particular example of an issue: this would conflict with any type of caching currently in use, either in ICS Calendar itself or other third-party caching plugins.)

I’m going to add this to the longer term to-do list for the project.

  • This reply was modified 36 minutes ago by room34.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer