iOS Question Change the app to other language with google translate

John Woodsmall

Active Member
Licensed User
Longtime User
Is there anyway to change the words in the app to a different language?

That is to change the app words like you can change the web page words into another language with google translate?
 

John Woodsmall

Active Member
Licensed User
Longtime User
wanted to have a drop down box (like the web translate, which now works, thanks!) to select the language.
any tutorial on how to create a google maps file; and how to activate them to change the language?(from a string)?
Also the labels on my app are hard coded in the designer, is there a simple way to re-write them?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It will not happen automatically.

You can create text files for each language. Each text file should look like:
label1=Hello
label2=World

You can read such files with File.ReadMap. Now you need to add a Tag to each of the labels you like to translate and do something like:
B4X:
Sub LoadStrings(FileName As String)
   Dim m As Map = File.ReadMap(File.DirAssets, FileName)
   For Each v As View In Page1.RootPanel.GetAllViewsRecursive
     If v Is Label And v.Tag <> Null And m.ContainsKey(v.Tag) Then
       Dim lbl As Label = v
       lbl.Text = m.Get(v.Tag)
     End If
   Next
End Sub
 
Upvote 0

John Woodsmall

Active Member
Licensed User
Longtime User
built map file (labels pairs)

B4X:
Log("CellClick: " & Col & " , " & Row)
    rx = Row
    language_name = Table7.GetValue(0,Row)
    language_abv = Table7.GetValue(1,Row)
    'Msgbox ("Language=" & language_name & " " & language_abv," ")
    MapFileName = language_abv & ".map"
    Log ("Mapfile name=" & MapFileName)
   Dim m As Map = File.ReadMap(File.DirAssets, MapFileName)
   For Each v As View In Page1.RootPanel.GetAllViewsRecursive
      Log("--" & v & v.Tag)
     If v Is Label And v.Tag <> Null And m.ContainsKey(v.Tag) Then
       Dim lbl As Label = v
       lbl.Text = m.Get(v.Tag)
      Log(lbl.Text)
     End If
   Next
End Sub
----------------------
Log:
CellClick: 0 , 0
Mapfile name=en.map
--<B4IViewWrapper: <UIImageView: 0x15ede400; frame = (0 0; 320 1022.5); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x15ede380>>>
(20 more lines...number of lines in map file):
...
this is en.map file
Button1="Clear"
Button12="OK - Birthday"
...(more lines)

not getting anything back, but this error message above?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…