Localization part 3 (#333)

* TODO

* TODO

* Add some translations

* Remote screen and settings

* Video player and http client
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-03-19 23:16:39 -04:00
1 parent 9a7db6aab2
commit 7330b321a5
19 files changed
+837 -85

No files matched your search

@@ -4,7 +4,9 @@ import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
function Init()
@@ -64,6 +66,11 @@ function OnNodeReady()
m.linkWithWifiPanel.visible = false
m.linkWithTvPanel.observeField("visible", FuncName(OnLinkWithTvPanelVisibleChanged))
m.linkWithTvPanel.visible = false
m.webAppButton.observeField("contentWidth", FuncName(OnButtonSizeChange))
m.linkWithWifiButton.observeField("contentWidth", FuncName(OnButtonSizeChange))
m.linkWithTvButton.observeField("contentWidth", FuncName(OnButtonSizeChange))
OnButtonSizeChange()
end function
function OnFocusChange() as void
@@ -86,6 +93,18 @@ function OnUrlSet()
m.webAppQrCodePoster.text = url
end function
function OnButtonSizeChange()
width1 = m.webAppButton.contentWidth
width2 = m.linkWithWifiButton.contentWidth
width3 = m.linkWithTvButton.contentWidth
width = MathUtils.Max(width1, MathUtils.Max(width2, width3))
m.webAppButton.minimumWidth = width
m.linkWithWifiButton.minimumWidth = width
m.linkWithTvButton.minimumWidth = width
end function
function OnkeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press)
if navigation.handled
@@ -134,12 +153,13 @@ function OnLinkWithWifiPanelVisibleChanged() as void
if connectionInfo.type = "WiFiConnection"
m.wifiNameLabel.text = connectionInfo.ssid
else if connectionInfo.type = "WiredConnection"
m.wifiNameLabel.text = "Wired connection"
m.wifiNameLabel.text = Tr(Locale.RemoteScreen.WiredConnection)
else
m.wifiNameLabel.text = "N/A"
end if
m.wifiInstructionWithDeviceNameLabel.text = `Tap the cast icon and select <Bold>"${m.loungeService.deviceName}"</Bold>`
deviceName = `<Bold>"${m.loungeService.deviceName}"</Bold>`
m.wifiInstructionWithDeviceNameLabel.text = Tr(Locale.RemoteScreen.WifiInstruction3).Replace("%1", deviceName)
end function
function OnLinkWithTvPanelVisibleChanged()
@@ -159,7 +179,7 @@ function GeneratePairingCode()
m.linkCodeTask.cancel = true
end if
m.linkCodeLabel.text = "Loading..."
m.linkCodeLabel.text = Tr(Locale.RemoteScreen.Loading)
m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, {
loungeService: m.loungeService
loungeToken: m.loungeService.loungeToken
@@ -187,8 +207,8 @@ function OnLoungeGenerateManualPairingCodeTaskResult(output as object) as void
error = ErrorUtils.Format(error)
LogError(error)
message = `Failed to generate manual pairing code\n${error}`
DialogUtils.ShowDialog(message, "Get TV code fail", true)
message = Tr(Locale.RemoteScreen.FailedToGeneratePairingCode) + `\n${error}`
DialogUtils.ShowDialog(message, Tr(Locale.RemoteScreen.TvCodeError), true)
return
end if
@@ -10,11 +10,13 @@
<Group id="noInternet" visible="false">
<Label
height="720"
width="1280"
font="font:MediumBoldSystemFont"
width="920"
font="font:SmallSystemFont"
horizAlign="center"
vertAlign="center"
text="Could not get IP address: are we connected to the internet?"
wrap="true"
translation="[180,0]"
/>
</Group>
<Group id="yesInternet" visible="false">
@@ -97,23 +99,23 @@
wrap="true"
text="Tap the cast icon and select this device." />
</LayoutGroup>
<Label
text="Roku connected to:"
translation="[0,220]">
<Font role="font" uri="font:SystemFontFile" size="20" />
</Label>
<Label
id="WifiNameLabel"
color="#4287f5"
translation="[0,250]">
<Font role="font" uri="font:BoldSystemFontFile" size="28" />
</Label>
</LayoutGroup>
<Label
text="Roku connected to:"
translation="[0,220]">
<Font role="font" uri="font:SystemFontFile" size="20" />
</Label>
<Label
id="WifiNameLabel"
color="#4287f5"
translation="[0,250]">
<Font role="font" uri="font:BoldSystemFontFile" size="28" />
</Label>
</Group>
<Group id="LinkWithTvPanel"
translation="[700,220]">
<LayoutGroup itemSpacings="[12]">
<LayoutGroup itemSpacings="[12,12,25]">
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label
font="font:SmallSystemFont"
@@ -132,7 +134,7 @@
font="font:SmallSystemFont"
width="380"
wrap="true"
text="Tap the Chromecast icon." />
text="Tap the cast icon." />
</LayoutGroup>
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label
@@ -142,18 +144,15 @@
font="font:SmallSystemFont"
width="380"
wrap="true"
text="Tap &quot;Link with TV code&quot; and enter the code below." />
text="Tap 'Link with TV code' and enter the code below." />
</LayoutGroup>
<Label
id="LinkCodeLabel"
font="font:LargeBoldSystemFont"
color="#4287f5">
<Font role="font" uri="font:BoldSystemFontFile" size="48" />
</Label>
</LayoutGroup>
<Label
id="LinkCodeLabel"
font="font:LargeBoldSystemFont"
color="#4287f5"
translation="[-30,180]"
width="460"
horizAlign="center">
<Font role="font" uri="font:BoldSystemFontFile" size="48" />
</Label>
</Group>
</Group>
</children>