Forum .LRN Q&A: Is localized cr_items.name necessary for file-storage?

In the file-storage applet for .LRN, several "built-in" folders are created such as assignments, syllabus, etc.

Currently a localized message key is stored in cr_folders.label and cr_items.name and is localized when it is used. This works great for cr_folders.label which is used for the web user interface display of the folder name.

It breaks browsing of the folders with the view feature, and new webdav support that uses the cr_items.name to resolve the URL because the folder URL looks like "<span>#</span>file-storage.Assignments#".

My idea is to localize the string before the folder is created for the name to the default locale of the openacs install. The folder label used to the display would still be shown in the users preferred locale.

Collapse
Posted by Ola Hansson on
Which branch are you experiencing this on, Dave?

I could be wrong but I think the view feature, at least, works on the oacs-5-0 branch. By this I mean that it works to have the "<span>#</span>package-key.Key#" in cr_items.name and also in the url after some massaging. See bug #1511:

https://openacs.org/bugtracker/openacs/com/dotlrn-fs/bug?filter%2estatus=closed&bug%5fnumber=1511

It might still cause trouble with webdav(b), though ... (?)

/Ola

I think it is not necessary to distinguish between user's view and system view. If on a German site a folder "Öffentliche Dateien of X" is created, a US guest switching his locale back to English will understand this and need not see "X's Public Files". He might even be confused seeing something else than his neighbor.
Collapse
Posted by Dave Bauer on
Ola, URLs with # shouldn't work. That is supposed to be the fragment identifier. Maybe the browser is luckily urlencoding it for you.

Matthias,

Maybe you are right. That is a seperate discussion though. If the name of the folder part of the localized user interface? Are class names localized in the same way?

Dave,
perhaps I do not even understand your question properly. File and class names do occur in nested localized messages, for instance, "Are you sure you want do delete #public-folder# and all of its content?" or the like. Names should remain constant, whereas the surrounding parts of the messages should be localized. But that's only my user's preference and I don't know about the intended design, as I said already here https://openacs.org/forums/message-view?message_id=167301
Collapse
Posted by Dave Bauer on
So you are saying that using the message key is wrong for the display name of the folder?

Right now the display name (cr_folders.label) for the folder is stored in the database as "<span>#</span>file-storage.Public_Files#" or something similar. So the string needs to be localized ever time it is displayed. You seem to be saying that the display name should be localized on creation and the localized name stored in the database. In this case the display name of the folder would not change, although the surrounding messages may change if a user has a different locale than the default system locale.

Collapse
Posted by Dave Bauer on
I want to clarify that the display name (cr_folders.label) has no consequence on the code I am writing for WebDAV support or on the /view/ feature URLs.

My original point is that the URL can change based on a users locale, which makes it difficult to write an application based on the URLs becuase currently the strings are not localized before the URL is resolved so we end up with something like /file-storage/<span>#</span>file-storage.Assignments# which is not a valid URL.

<blockquote> You seem to be saying that the display name should be
localized on creation and the localized name stored in
the datbase. In this case the display name of the folder
would not change,
</blockquote>

yes, Dave, I think that would suffice for most educational users.

Collapse
Posted by Ola Hansson on
"Ola, URLs with # shouldn't work. That is supposed to be the fragment identifier. Maybe the browser is luckily urlencoding it for you."

Dave, the browser wasn't luckily urlencoding the URL - I added code which does this explicitly before the href is rendered. See: http://cvs.openacs.org/cvs/openacs-4/packages/file-storage/www/folder-chunk.tcl?r1=1.15.2.3&r2=1.15.2.4

By default, "ns_conn url" and friends will decode the encoded hashes back into the original shape so that the returned paths, path fragments, or whatever will properly match strings with localizable keys fetched from the db. If the href is NOT urlencoded beforehand, though, the URL shown in the browser's address field will still contain ENCODED hashes, but - in the "view" index.vuh, for instance - "ns_conn url" will choke on the first hash and cut the URL right there ...

As for the validity of the URL: /file-storage/<span>#</span>file-storage.Assignments# is apparently not a valid URL, but /file-storage/%23file-storage.Assignments%23 is - or so it seems.

/Ola

Collapse
Posted by Dave Bauer on
Ola,

Aha!

Ok that makes sense. I still don't see a good reason to create the URL like that though :) So yes, a URL should be urlencoded, but that doesn't mean that we should store a message key as the URL.

So, I probably should make the webdav software url encode the urls anyway, because if I change the behavior of the file-storage applet, that doesn't mean it won't show up somewhere else, and it should make it safe to use unicode characters in a URL or filename as well.

Yeah, I agree.

Notice that I used a regexp to encode the "#". That was because neither ns_urlencode nor ad_urlencode did this ... (Note to self; might this be a subtle indication as to not incude #'s in URLs? 😉

Anyway, I have no strong opinion how this is revamped - but wouldn't it make most sense to simply never apply localization on the name (I'm not talking about the label where I do think it makes great sense)? That is, skip the key altogether.

/Ola

The note above to you and I is false 😟

I couldn't use *_urlencode because then the slashes were being encoded and no longer matched the delimiter "/" in the code which calculates the cr_item.

And that's the truth ...

/Ola

Collapse
Posted by Dave Bauer on
Ola,

I did a split $uri "/" and urlencoded each part, then joined it back together.

It appears that MS WebFolders clients still connect handle the URLs even if they are urlencoded, so the best bet is going to be to take out the message keys and use the system locale for the folder URLs.