Hello,
I am working on localizing my channel and I wanted to use the
GetLocalizedAsset
function as this is documented as the proper way to pull localized assets.
I am using an
roListScreen
and populating it with:
contentList = [
{
Title: tr("Live Stream"),
ID: "1",
'SDSmallIconUrl: "pkg://locale/default/images/live_stream_small.png",
'HDSmallIconUrl: "pkg://locale/default/images/live_stream_small.png",
'HDBackgroundImageUrl: "pkg://locale/default/images/live_stream_poster_art_hd.png",
'SDBackgroundImageUrl: "pkg://locale/default/images/live_stream_poster_art_sd.png",
HDBackgroundImageUrl: GetLocalizedAsset("images", "live_stream_poster_art_hd.png"),
SDBackgroundImageUrl: GetLocalizedAsset("images", "live_stream_poster_art_sd.png"),
ShortDescriptionLine1: tr("Live Stream"),
ShortDescriptionLine2: tr("Broadcasting around the world"),
CallBack: LiveStream
},
{
Title: tr("Alternate Language Live Stream"),
ID: "2",
'SDSmallIconUrl: "pkg://locale/default/images/alt_stream_small.png",
'HDSmallIconUrl: "pkg://locale/default/images/alt_stream_small.png",
'HDBackgroundImageUrl: "pkg://locale/default/images/alt_stream_poster_art_hd.png",
'SDBackgroundImageUrl: "pkg://locale/default/images/alt_stream_poster_art_sd.png",
ShortDescriptionLine1: tr("Alternate Language Live Stream"),
ShortDescriptionLine2: tr("Alternate language of our live stream"),
CallBack: AltLangStream
},
{
Title: tr("About Us"),
ID: "3",
'SDSmallIconUrl: "pkg://locale/default/images/about_small.png",
'HDSmallIconUrl: "pkg://locale/default/images/about_small.png",
'HDBackgroundImageUrl: "pkg://locale/default/images/about_us_poster_art_hd.jpg",
'SDBackgroundImageUrl: "pkg://locale/default/images/about_us_poster_art_sd.png",
ShortDescriptionLine1: tr("About Us"),
ShortDescriptionLine2: tr("Some basic information about us"),
CallBack: AboutUs
}
]
As you can see I just commented out the code that works (absolute path) but when I use the
GetLocalizedAsset
function I get the following error in the debug console:
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in ...g:/source/mainContentList.brs(12)
012: HDBackgroundImageUrl: GetLocalizedAsset("images", "live_stream_poster_art_hd.png"),
Backtrace:
Function maincontentlist() As Object
file/line: /tmp/plugin/MHAAAAdaPRGG/pkg:/source/mainContentList.brs(12)
Function main() As Void
file/line: /tmp/plugin/MHAAAAdaPRGG/pkg:/source/main.brs(16)
Local Variables:
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=3
contentlist &h0000 <uninitialized> val:Uninitialized
getlocalizedasset &h0000 <uninitialized> val:Uninitialized
line 12 is:
HDBackgroundImageUrl: GetLocalizedAsset("images", "live_stream_poster_art_hd.png"),
Am I using this wrong? Can this not be using in the main.brs? My main.brs is:
' ******************************************************************
' * This is the main function, this is the channel's starting point
' ******************************************************************
Sub Main()
print "Channel Initialized - ";
' Initialize the theme
InitTheme()
' Create screen and event listener port (roMessagePort)
screen = CreateObject("roListScreen")
port = CreateObject("roMessagePort")
' Set lister port to screen
screen.SetMessagePort(port)
' Set screen content title
screen.SetHeader( tr("Welcome to the Sonlife Network") )
' Initialize content list (main page)
contentListOptions = MainContentList()
' Assign the content list to the screen
screen.SetContent(contentListOptions)
' Show the content list
screen.show()
' Keep channel open and monitor event listener
while (true)
' Define event
event = wait(0, port)
' Check if current screen event
if (type(event) = "roListScreenEvent")
print "----------------------[ Main Page | roListScreenEvent ]----------------------"
' Check for focused item
if (event.isListItemFocused())
print "Calling Title for index: " ; event.GetIndex()
' Update breadcrumb
screen.SetBreadcrumbText(tr("Menu"), contentListOptions[event.GetIndex()].Title)
print "Calling Title Complete"
else if (event.isListItemSelected())
print "Calling Callback for index: " ; event.GetIndex() ; " - " ; contentListOptions[event.GetIndex()].Title
' Do callback when selected
contentListOptions[event.GetIndex()].CallBack()
print "Callback Complete"
endif
endif ' End Check for events
end while ' End Keep channel open
End Sub
' Checks if display is HD
Function isHD() As Boolean
di = CreateObject("roDeviceInfo")
if di.GetDisplayType() = "HDTV"
print "HDTV"
return true
else
print "Regular TV"
return false
end if
End Function
' Gets the current locale
Function getLocale() As String
di = CreateObject("roDeviceInfo")
return di.GetCurrentLocale()
End Function
MainContentList()
returns the code I pasted above.
Any help/insight on why this is throwing an error would be much appreciated.
My file structure is:
locale
|--- default
|--- images
|--- en_US
|--- images
|--- es_ES
|--- images
source
Thanks