Can Sparkle fetch localized release notes if available when checking for updates?

Asked by smorr

One of the things I noticed in the rss xml feed is that <sparkle:releaseNotesLink> points to a single file. Is it possible for Sparkle to read the current localized language of the user and get directed to an appropriate release notes localization if available (defaulting to whatever the developer wants if not available)

Scott

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
smorr (smorr) said :
#1

I have done the work to code this if you are interested --
In the xml feed, specify the language using an attribute and multiple < sparkle:releaseNotesLink nodes>
(I don't know if this is proper xml -- but it can be fixed as you like)
        <sparkle:releaseNotesLink language="fr">http://www.indev.ca/sparkle/frenchNotes.html</sparkle:releaseNotesLink>
        <sparkle:releaseNotesLink language="en">http://www.indev.ca/sparkle/englishNotes.html</sparkle:releaseNotesLink>

I have the tweaked code for SUAppcastItem.m and SUAppcast.m -- Is there a way to get it to you.

Revision history for this message
Hofman (cmhofman) said :
#2

The *supported* way to do this is to have separate appcasts for your languages, and supply the feedURL for the proper language through the delegate method.

This also is better as you can use the built-in algorithm to determine the proper language (just store the URLs in localized files in your Resources). Any solution like smorr's would require Sparkle to use a custom, and therefore more fragile, algorithm to determine the best language.

Revision history for this message
smorr (smorr) said :
#3

It is probably a better method -- what you are describing but...

If you are referring to the method -[SUUpdater feedURL]

I see where it is calling on the delegate method
-[NSObject feedParametersForHostBundle:sendingSystemProfile:]

I can see were it set the parameters (sys vers etc) that it sends but it always refers to _baseFeedURL which either uses the info.plist feed url or the one that is stored in defaults (which I want to reserve for a beta feed)

ie as far as I tell, the delegate method will only provide parameters but not allow the delegate to change up the base url according to the localization.

Am I not seeing something?

Revision history for this message
Andy Matuschak (andymatuschak) said :
#4

Hm. You know, I think I actually used to support something like this. The key is that XML has a standard attribute called xml:lang which is supposed to be used for basically this very purpose: localized alternatives to elements.

I should probably reimplement support for xml:lang. In the meantime, yes, you can call setFeedURL on SUUpdater to change it.

Revision history for this message
smorr (smorr) said :
#5

Maybe because I am using 1.5b4 and it has be added in more recent builds, but SUUpdater doesn't have a setFeedURL method.

Revision history for this message
Andy Matuschak (andymatuschak) said :
#6

It has been added in more recent builds. I'm aiming for 1.5b5 this weekend, though.

Revision history for this message
Hofman (cmhofman) said :
#7

Sorry, I was confused. It's indeed a pref rather than a delegate method. If you want to use that for beta as well, that would not be a reason not to use it. Just use various localized versions for release+lang or beta+lang. And setFeedURL: in the recent source is just a shortcut for setting this user default (as the pref key is supposed to be private). I can't see xml:lang used in any release (I checked 1.1.1, 1.1.2, and 1.5b2 up to 1.5b4). And it would have the problem I noted that it you can't use the system's algorithm to find the best localization.

Revision history for this message
Hofman (cmhofman) said :
#8

Seems you can do this using +[NSBundle preferredLocalizationsFromArray:].

Revision history for this message
smorr (smorr) said :
#9

Also consider [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]

will give the ordered array of language codes (eg: en,fr, de etc) that the user has set in their system preferences (ordered according to their preferences)

What I have done in my code is to walk through these until I find a language that matches a language given in the xml feed.

Revision history for this message
smorr (smorr) said :
#10

In anycase -- I will look at the specs for xml:lang and see if I can code something that would be a standard to use.

Revision history for this message
Hofman (cmhofman) said :
#11

Directly using AppleLanguages is what I mean by fragile and circumventing the system frameworks, which usually is bad to do. I wonder if you've taken into account the relation between English, en, en-US, en-GB etc? This is my point about using a system provided API like preferredLocalizationsFromArray:. Anyway, given that access to the system's algorithm exists it makes sense to use xml:lang.

Can you help with this problem?

Provide an answer of your own, or ask smorr for more information if necessary.

To post a message you must log in.