Android Question B4X Localizator a small problem

kisoft

Well-Known Member
Licensed User
Longtime User
I use this method with great success.I have a problem with the translation of the Activity.AddMenuItem elements, EditText( Hint Text), ListView1, ToastMessageShow.
 

kisoft

Well-Known Member
Licensed User
Longtime User
edittext1 is on panel1 there is still no hint text translation.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("logowanie")
    Starter.loc.LocalizeLayout(Activity)
    For Each pnl In Array(Panel1)
    Starter.loc.LocalizeLayout(pnl)
Next
    Starter.loc.LocalizeLayout(Activity)
    
    Activity.AddMenuItem ("widok1","openfile1")
    Activity.AddMenuItem ("widok2","openfile2")
    Activity.AddMenuItem ("widok3","openfile3")
    Activity.AddMenuItem ("widok4","openfile4")
    Activity.AddMenuItem ("widok5","openfile5")
    Activity.AddMenuItem ("widok6","openfile6")
    Activity.AddMenuItem ("widok7","openfile7")
    Activity.AddMenuItem ("Wybierz język","openfile8")
        
    Activity.AddMenuItem(Starter.Loc.Localize("widok1"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok2"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok3"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok4"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok5"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok6"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("widok7"), True)
    Activity.AddMenuItem(Starter.Loc.Localize("Wybierz język"), True)
    
    ToastMessageShow(Starter.Loc.Localize("złe hasło spróbuj ponownie"), True)

Activity.AddMenuItem is translated but the translation is added to the drop-down items.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are not using Loc.Localize correctly.

Unlike LocalizeLayout, it doesn't go over existing items and change them. Given the key, it returns the localized value.

Your code should be:
B4X:
    Activity.AddMenuItem (Starter.Loc.Localize("widok1"),"openfile1")
   '...
Don't add any menu item without localizing the string.

You can also use Localize to localize the EditText hint.
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Thank you for help, everything works.

B4X:
EditText1.Hint=Starter.Loc.Localize("text for translation")
 
Upvote 0
Top