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.
 
edittext1 is on panel1 there is still no hint text translation.

Code: Copy
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
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:
Code: Copy
    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
Thank you for help, everything works.

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