B4J Code Snippet [B4X] [B4XPages] Localizator

I can't find an example of using Localizator in B4XPages so I tried to make it work in B4XPages with a simple example.

1662539661661.png
1662539695377.png
1662540263983.png


Main module:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Public Loc As Localizator
End Sub

B4XMainPage:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Main.Loc.Initialize(File.DirAssets, "strings.db")
    LocalizePage ' apply Localization
   
    B4XPage2.Initialize
    B4XPages.AddPage("Page2", B4XPage2)
End Sub

Sub LocalizePage
    Log("Localizing MainPage...")
    Main.Loc.ForceLocale("zh")
    Main.Loc.LocalizeLayout(Root)
End Sub

Page2 class:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Page2")
    Log("Localizing Page2...")
    Main.Loc.LocalizeLayout(Root)
    Label1.Text = Main.Loc.LocalizeParams(Label1.Text, Array(2))
    B4XPages.SetTitle(Me, Label1.Text)
End Sub
 

Attachments

  • B4XPagesLocalizator.zip
    20 KB · Views: 90
Last edited:
Top