This topic viewtopic.php?f=34&t=96416 draw my attention to there being some attempts of image localization in RSG URLs - but as reported, seems that is broken or not implemented. Fingers crossed it is not working as documented indeed, because i have a better proposal
What is documented is an unnecessarily complicated, over-designed and yet limited and limiting process of looking up resources with URI starting with "pkg:/locale/". Shortfalls:
It's is confusing for the developer (i had to do multiple passes reading the algorithm - others complained the same)
Looky here, lookie there - it's like a shell game, just a "busy work" for the player to search multiple places
Does not support "proper" URLs (e.g. "http://...") - and this is a BFD for an online device. What good is Roku's localization if i cannot reap benefits fetching localized images/audio/video from the Net?
Unnecessarily restrictive on how directories should be organized (pkg:/locale/fr_CA/images/logo.jpg - why, what if i prefer pkg:/images/fr_CA/logo.jpg or pkg:/images/logo-fr_CA.jpg ?)
So, instead i propose something simpler, broader, faster - and overall more elegant, easier to comprehend: a macro!
I did not invent the concept - and that's why it would be easier for the developers, they know it. Just have a literal like say $LCID if encountered in URIs, expanded to the current locale id and ... be done with the shell-game gallimaufry! That's all, folks. Then the player "magically"-yet-unsurprisingly will be able to get my resources from places like:
In addition, let's improve roLocalization - so that its method getLocalizedAsset(dirName, fileName) starts making some sense! My proposal is to allow (optional) template parameter in the constructor:
loc = CreateObject("roLocalization", "pkg:/images/locale=$LCID/$FILENAME") >>> ? GetLocalizedAsset("", "MyImage-$LCID.png") pkg:/images/locale=en_US/MyImage-en_US.png
The template param being optional, if not provided it will be assumed (defaults to) "pkg:/locale/$LCID/$DIRNAME/$FILENAME" to maintain compatibility with current behavior. Note the example above is unnaturally contrived for the same of demonstrating double macro expansion.